Boost logo

Boost :

Subject: Re: [boost] Checking for return type -- BOOST_STATIC_ASSERT?
From: Edward Grace (ej.grace_at_[hidden])
Date: 2009-08-21 06:47:47


>>
>> #include <boost/mpl/assert.hpp>
>>
>> int main() {
>> BOOST_MPL_ASSERT(( boost::is_same<unsigned,unsigned> )); //
>> Should be ok!
>> return 0;
>> }
[snip]
>
> You should also include <boost/type_traits/is_same.hpp>

Duh - feeling pretty dim.....

#include <boost/mpl/assert.hpp>
#include <boost/type_traits/is_same.hpp>

int main() {
   BOOST_MPL_ASSERT(( boost::is_same<unsigned,double> )); // Should die!
   return 0;
}

/sw/bin/g++-4 -I/usr/local/include -ansi -pedantic -Wall test.cpp
test.cpp: In function 'int main()':
test.cpp:6: error: no matching function for call to 'assertion_failed
(mpl_::failed************ boost::is_same<unsigned int,
double>::************)'

Bingo!

Cheers,

Now to try and build my castle in the sky (lets face it that's what a
lot of this feels like at times).....

-ed


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