Boost logo

Boost Users :

From: John Maddock (john_at_[hidden])
Date: 2007-08-10 04:45:32


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<operatorT,
>>>>> 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<A, B>::value));

HTH, John.


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