
On Fri, 25 Feb 2005 08:48:09 -0800 "Eric Niebler" <eric@boost-consulting.com> 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...