Boost logo

Boost Users :

From: Shunsuke Sogame (mb2act_at_[hidden])
Date: 2006-11-30 07:17:53


craigp wrote:
> For some reason, I can't get the IDE to compile BOOST_MPL_ASSERT. I tried this:
>
> #include <boost/type_traits/is_same.hpp>
> #include <boost/mpl/assert.hpp>
>
> int main()
> {
> BOOST_MPL_ASSERT(( boost::is_same< char, char > ));
> }
>
> and it gives the following errors:
>
> d:\dev\boost.cvs\boost\libs\fusion\example\extension\test_example.cpp(31) :
> error C2143: syntax error : missing ';' before '='
> d:\dev\boost.cvs\boost\libs\fusion\example\extension\test_example.cpp(31) :
> error C2143: syntax error : missing ';' before '='
>
> what's even stranger is that i copied/pasted the pre-processed file, and that
> compiled just fine:
>
> static const std::size_t mpl_assertion_in_line_26 = sizeof(
> boost::mpl::assertion_failed<false>( boost::mpl::assert_arg( (void (*) (
> boost::is_same< char, char > ))0, 1 ) ) );
>
> anyone else seen something like this before?? all the mpl regression tests
> compile fine via bjam (using msvc 7.1), so it appears ide-specific, somehow...

Hmm, I found: http://tinyurl.com/y6vxr7
IDE banishes __LINE__ out of constants?

#define MYLINE __COUNTER__ // compiles
// #define MYLINE __LINE__ // fails

#define MY_MPL_ASSERT(pred) \
enum { \
     BOOST_PP_CAT(mpl_assertion_in_line_,MYLINE) = sizeof( \
           boost::mpl::assertion_failed<false>( \
               boost::mpl::assert_arg( (void (*) pred)0, 1 ) \
             ) \
         ) \
}\
/**/

int main()
{
     MY_MPL_ASSERT(( boost::is_same< char, char > ));
}

-- 
Shunsuke Sogame

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net