Boost logo

Boost :

From: Matthias Schabel (boost_at_[hidden])
Date: 2007-01-27 01:39:03


> hmmm...decided to try and test this guy out and based on the docs I
> would think the following code would compile, but it doesn't in VC++
> 8.0...g++ gobbles it up ok though.

A better fix is to replace the code between the #ifdef
MCS_HAS_TYPEOF ... #endif // MCS_HAS_TYPEOF with the following:

#ifdef MCS_HAS_TYPEOF
template<typename X> struct unary_plus_typeof_helper { typedef
typeof(+X()) type; };
template<typename X> struct unary_minus_typeof_helper { typedef
typeof(-X()) type; };

template<typename X,typename Y> struct add_typeof_helper { typedef
typeof(X()+Y()) type; };
template<typename X,typename Y> struct subtract_typeof_helper
{ typedef typeof(X()-Y()) type; };
template<typename X,typename Y> struct multiply_typeof_helper
{ typedef typeof(X()*Y()) type; };
template<typename X,typename Y> struct divide_typeof_helper
{ typedef typeof(X()/Y()) type; };
#else // MCS_HAS_TYPEOF
template<typename X> struct unary_plus_typeof_helper { typedef X
type; };
template<typename X> struct unary_minus_typeof_helper { typedef X
type; };

template<typename X,typename Y> struct add_typeof_helper
{ BOOST_STATIC_ASSERT((is_same<X,Y>::value == true)); typedef X type; };
template<typename X,typename Y> struct subtract_typeof_helper
{ BOOST_STATIC_ASSERT((is_same<X,Y>::value == true)); typedef X type; };
template<typename X,typename Y> struct multiply_typeof_helper
{ BOOST_STATIC_ASSERT((is_same<X,Y>::value == true)); typedef X type; };
template<typename X,typename Y> struct divide_typeof_helper
{ BOOST_STATIC_ASSERT((is_same<X,Y>::value == true)); typedef X type; };
#endif // MCS_HAS_TYPEOF

Matthias


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