boost static assert and is_base_of question.

Hi, how would I ensured that class U of template class is a dervied class of
boost::operators<U> using BOOST_STATIC_ASSERT and boost::is_base_of...
template <T>
myFunc(const T& a)
{
typedef boost::operators<T> operatorT;
BOOST_STATIC_ASSERT(is_integral<T>::value || is_base_of

chun ping wang wrote:
Hi, how would I ensured that class U of template class is a dervied class of boost::operators<U> using BOOST_STATIC_ASSERT and boost::is_base_of...
template <T> myFunc(const T& a) { typedef boost::operators<T> operatorT; BOOST_STATIC_ASSERT(is_integral<T>::value || is_base_of
value); // ... other codes. }
doing this gives me an error.
Right, since BOOST_STATIC_ASSERT is a macro, you need some extra parenthesis to stop the "," in the template arg list to is_base_of from being seen as a macro-argument separator: BOOST_STATIC_ASSERT((is_base_of::value)); HTH, John.
participants (2)
-
chun ping wang
-
John Maddock