
26 Sep
2007
26 Sep
'07
7:07 p.m.
template <typename T> bool boost::pseudoprime(const T& n, const T& k) { typedef boost::operators<T> operatorT; BOOST_STATIC_ASSERT(is_integral<T>::value); // static assert 1. BOOST_STATIC_ASSERT((is_base_of<operatorT, T>::value)); // static assert 2. BOOST_ASSERT (n > T(2) && n % T(2) != 0); return modular_expo(k, n-1, n) != T(1) % n ? true : false; } now in vistual studio 2005 sp1 and visual studio 2008 beta the part "is_base_of<operatorT, T>::value" does not work if T happens to be an int or long due to "error C2803: 'operator --' must have at least one formal parameter of class type". I want to use enable_if to enable the STATIC_ASSERT only if T is NOT an arithmetic type for static assert 2. How would i go about doing that?