|
Boost : |
From: David Abrahams (dave_at_[hidden])
Date: 2002-09-08 12:33:09
From: "Craig Henderson" <cdm.henderson_at_[hidden]>
> I have a problem with the BOOST_STATIC_ASSERT macros on VC++.Net. My
class
...
> Please could someone explain this behaviour? Am I missing something or
there
> something wrong with the macro or vc++ compatibility?
Expressions passed to BOOST_STATIC_ASSERT can only be compile-time
expressions (thus the word STATIC in the name), but typeid() is a runtime
expression. If you want a runtime assert, use <cassert>. If you want to
assert that types are the same at compile-time, try:
#include <boost/type_traits.hpp>
...
BOOST_STATIC_ASSERT((
boost::is_same<typename Res::value_type, diff_result<T>*>::value));
or if you want equivalent behavior to your typeid() expression:
BOOST_STATIC_ASSERT((
boost::is_same<
typename boost::remove_cv<
typename boost::remove_reference<
typename Res::value_type
>::type
>::type
, diff_result<T>*
>::value
));
HTH,
Dave
-----------------------------------------------------------
David Abrahams * Boost Consulting
dave_at_[hidden] * http://www.boost-consulting.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk