need for typedef for instances of template classes

P

puzzlecracker

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
 
J

John Harrison

puzzlecracker said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top