• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: template C++ mailing lists
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: template C++ mailing lists


  • Subject: Re: template C++ mailing lists
  • From: Andrew Gross <email@hidden>
  • Date: Thu, 22 Feb 2007 12:59:32 -0800


The most common use of the preprocessor with respect to templates is to generate parameter lists for templates that take a variable amount of type arguments, such as boost::tuple or boost::function, where one must provide a specialization for each argument count.


Take a look at /usr/include/c++/4.0.0/tr1/bind_repeat.h and repeat.h to get an idea of what I'm talking about.

As for the preprocessor, it does absolutely nothing to the templates themselves. Template instantiation is done by the compiler.


On Feb 22, 2007, at 12:52 PM, Wesley Smith wrote:

As an example, there is the well known Factoriol template class that
does actually compute the factorial of a number at compile time.  Most
of the examples I've seen that do this kind of trick are numerical or
grammatical in nature like template expression trees.  I'm still
learning the subtleties of C++ templates w/r/t what can be done in the
preprocessor.  This isn't really the place for a discussion on it, but
oh how I wish C++ compilers could do compile-time string processing
like hashing a string into an enum.

wes

On 2/22/07, David A Rowland <email@hidden> wrote:
At 9:21 PM +0100 2/22/07, Stefan Werner wrote:
>On Feb 22, 2007, at 8:06 PM, Thomas Engelmeier wrote:
>
>>>Also, when dealing with C++ and templates: Build/Preprocss is your
>>>best friend!
>>
>>What have templates to do with the preprocessor?
>>They were partially invented to get rid of dirty C macro tricks....
>
>Yes, and templates too get expanded by the preprocessor. So if you
>want to see the same code that the compiler sees (and in cases,
>gives you error messages about), is what comes out of the
>preprocessing step.


Using Xcode 2.4.1 when I Build/Preprocess a .cpp file it creates a .i file, but the templates are not instantiated. Is that what you mean by "expanded"?

As I understand it, the preprocessor only deals with # commands. The
preprocessor is ignorant of templates, C or C++ syntax or namespaces.


David
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40gmail.com


This email sent to email@hidden

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden

_______________________________________________ Do not post admin requests to the list. They will be ignored. Xcode-users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >template C++ mailing lists (From: "Wesley Smith" <email@hidden>)
 >Re: template C++ mailing lists (From: John Daniel <email@hidden>)
 >Re: template C++ mailing lists (From: Stefan Werner <email@hidden>)
 >Re: template C++ mailing lists (From: Thomas Engelmeier <email@hidden>)
 >Re: template C++ mailing lists (From: Stefan Werner <email@hidden>)
 >Re: template C++ mailing lists (From: "Wesley Smith" <email@hidden>)

  • Prev by Date: Re: template C++ mailing lists
  • Next by Date: Re: template C++ mailing lists
  • Previous by thread: Re: template C++ mailing lists
  • Next by thread: Re: template C++ mailing lists
  • Index(es):
    • Date
    • Thread