Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > need for typedef for instances of template classes

Reply
Thread Tools

need for typedef for instances of template classes

 
 
puzzlecracker
Guest
Posts: n/a
 
      09-16-2005
In Sutter's book - More Exceptional C++, on page 27 - there is

typedef IsDerivedFrom1<t, Cloanable > Y;

where he specifies that "typedef is needed it otherwise the , will be
interpeted as delimiting macro parameters to assert.

assert(Y:Is);

etc...

why would it be interpetted this way? if that the case, typename is
need. someone please explain

 
Reply With Quote
 
 
 
 
John Harrison
Guest
Posts: n/a
 
      09-16-2005
puzzlecracker wrote:
> In Sutter's book - More Exceptional C++, on page 27 - there is
>
> typedef IsDerivedFrom1<t, Cloanable > Y;
>
> where he specifies that "typedef is needed it otherwise the , will be
> interpeted as delimiting macro parameters to assert.
>
> assert(Y:Is);
>
> etc...
>
> why would it be interpetted this way? if that the case, typename is
> need. someone please explain
>


In

assert(IsDerivedFrom1<t, Cloanable >::Is);

The comma is indeed interpreted as seperating two macro parameters. This
is because macro substitution is done before anything else (more or less).

Not sure why you think typename is also needed, that would depend on the
context.

john
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
typedef of template<T> x to member x in template class squarewave@blockhead.net C++ 1 02-20-2009 08:15 PM
CRTP-problem: How can the base class typedef a derived class' typedef? oor C++ 0 05-20-2008 12:39 PM
Extracting template types from a typedef'd template declaration Adam Nielsen C++ 3 10-19-2007 09:54 AM
typedef of template classes are always default constructed? aaragon C++ 12 11-08-2006 04:34 PM
list of class instances within a list of a class instances John Wohlbier Python 2 02-22-2004 08:41 AM



Advertisments