Boost logo

Boost :

From: Jody Hagins (jody-boost-011304_at_[hidden])
Date: 2005-02-25 12:20:16


On Fri, 25 Feb 2005 08:48:09 -0800
"Eric Niebler" <eric_at_[hidden]> wrote:

> Please have a look at the article just published at the C++ Source
> (http://www.artima.com/cppsource/index.jsp) entitled "Conditional
> Love". If you want a BOOST_TYPEID macro that accepts an expression and
> returns the type_info without evaluating the expression, it's really
> quite simple:
>
> template<typename T>
> T const * encode_type( T const & ) {
> return 0;
> }
>
> template<typename T>
> type_info type_id_helper( T const * ) {
> // return type_info for type T
> }
>
> #define BOOST_TYPEID( expr ) \
> type_id_helper( true? 0 : encode_type( expr ) )
>
>
> With carefully selected overloads of encode_type and type_id_helper,
> you can correctly handle cv-qualifier and rvalues/lvalues.

Thanks, Eric. I will print it out and read it over the weekend...


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