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:06:34


On 20 Aug 2009, at 23:57, Scott McMurray wrote:

> 2009/8/20 Edward Grace <ej.grace_at_[hidden]>:
>>
>> if O is compatible with the concept of a functor and O returns a
>> type that
>> can be converted to a float, then we are good to go -- otherwise
>> I'd like an
>> intelligible error.
>>
>> If, for example, O is of the type 'void (*)()' I'd like it (the
>> compiler) to
>> spit out,
>> "The function pointer of type O must of signature float (*)()"
>>
>
> Sounds like you want something like the MPL_ASSERT example at [1]
> along with the result_of metafunction[2].

I'm starting to wonder if there's a problem with BOOST_MPL_ASSERT in g
++, as I understand it (this is quite probably the real problem....)
the following minimal example should work

#include <boost/mpl/assert.hpp>

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

When compiling,

/sw/bin/g++-4 -I/usr/local/include -ansi -pedantic -Wall test.cpp
test.cpp: In function 'int main()':
test.cpp:4: error: expected primary-expression before 'enum'
test.cpp:4: error: expected ';' before 'enum'

Pre-processing (and smartening up for presentation) we get,

int main() {
   static __const std::size_t mpl_assertion_in_line_4 =
   sizeof( boost::mpl::assertion_failed<false>(
     boost::mpl::assert_arg( (void (*)
( boost::is_same<unsigned,unsigned> ))0, 1 ) // <--- ))0,1 ) ????
     )
   ) ; // Should be ok!
   return 0;
}

-ed


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