Boost logo

Boost :

From: Reece Dunn (msclrhd_at_[hidden])
Date: 2003-12-10 13:35:53

Jeremy Maitin-Shepard wrote:

>What is the advantage in typing "BOOST_TYPENAME" when it would _always_
>be semantically equivalent to "class"?

One of the applications of the typename keyword is to signify a *type* as
opposed to a class in a template argument. This means that

template< typename T, class Traits >
struct typename_demo
   typedef typename Traits::value_type value_type; // ok
   typedef typename T::arg_type arg_type; // T is a type, not a class

This means that T can be int, float, ... as well as being a class. Although
the code above will not generate an error by the compiler, it is intended
for the developer to see that the second template argument must be a class,
not an int, for example.

BOOST_TYPENAME would be implemented as

# define BOOST_TYPENAME typename
# define BOOST_TYPENAME class // older compilers

and thus you can retain the above distinction while supporting non-compliant

Reece H Dunn

Hotmail messages direct to your mobile phone

Boost list run by bdawes at, gregod at, cpdaniel at, john at