Boost logo

Boost :

From: Reece Dunn (msclrhd_at_[hidden])
Date: 2003-12-10 12:07:36


David Abrahams wrote:

>"John Maddock" <john_at_[hidden]> writes:

> >> [3] When using BOOST_DEDUCED_TYPENAME, should it be used in all
>contexts
> >> other than in template parameters, e.g.

> >> template< typename T > // ok
> >> struct demo
> >> {
> >> typedef BOOST_DEDUCED_TYPENAME T::type type;
> >> typedef std::list< BOOST_DEDUCED_TYPENAME T::value_type > list;
> >> };

> > No, probably only in deduced contexts - see the test program for that
>macro
> > for an example.

>Actually on compilers where it's needed, it seems to be safe (and
>occasionally neccessary) to use it everywhere except in the place
>labelled OK above. We really ought to change it to BOOST_TYPENAME.

I think the name should be kept - it is already in use, so changing it may
break a lot of code. Also, the name indicates the use of typename in the
   BOOST_DEDUCED_TYPENAME T::type type
context, signifying meaning.

>( this might be another reason to write template<class T> ;-> )

Here would be a good use for a BOOST_TYPENAME, that becomes typename for
compilers that support it, and class for those that don't. Thus, my example
would become:

template< BOOST_TYPENAME T >
struct demo
{
   typedef BOOST_DEDUCED_TYPENAME T::type type;
   typedef std::list< BOOST_DEDUCED_TYPENAME T::value_type > list;
};

This would still allow you to signify a type (as opposed to just a class)
within a template, e.g.:

template< BOOST_TYPENAME CharT, class CharTraits >
class demo2
{
   // ...
};

Regards,
Reece H Dunn

_________________________________________________________________
Express yourself with cool emoticons - download MSN Messenger today!
http://www.msn.co.uk/messenger


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk