Compiling C++ Templates as opposed to Preprocessing them.

Seima Rao <seimarao@gmail.com>
Tue, 27 Jul 2010 13:36:42 +0530

          From comp.compilers

Related articles
Compiling C++ Templates as opposed to Preprocessing them. seimarao@gmail.com (Seima Rao) (2010-07-27)
Re: Compiling C++ Templates as opposed to Preprocessing them. alex.colvin@valley.net (mac) (2010-07-31)
Re: Compiling C++ Templates as opposed to Preprocessing them. zaimoni@zaimoni.com (Kenneth 'Bessarion' Boyd) (2010-08-16)
| List of all articles for this month |

From: Seima Rao <seimarao@gmail.com>
Newsgroups: comp.compilers
Date: Tue, 27 Jul 2010 13:36:42 +0530
Organization: Compilers Central
Keywords: C++, performance, question
Posted-Date: 27 Jul 2010 10:36:05 EDT

Hi,


        Can readers of this forum advise on whether it would be
        fruitful to consider compiling C++ templates to
        IR instead of preprocessing them?


        Consider the following snippet:


          template<class T>
          void
          foo(const T &t)
          {
                  T::i; // #1
          }


          Since the compiler cannot tell if `i' is a static member of `T',
          an extra operator needs to be introduced in the IR so that
          the `::' operator can be mapped to it. This operator would
          have no use in a non-generic scope, therefore, that operator
          is there merely to represent templates in the IR.


          I am sure professional compiler writers would have
          (many) non-trivial issues to tell.


          What I want to know is the following:


                  1) Has C++ been defined to accomodate compilation of templates?
                  2) Is name resolution unambiguously doable in template scopes
                          so that IRs that represent templates dont have to worry about
                          it at all?


Sincerely,
Seima Rao.



Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.