Boost logo

Boost :

From: Kenneth Ho (ken_at_[hidden])
Date: 2007-10-11 12:47:57


I ran into a scenario where enable_if worked, but not enable_if_c, using
MSVC 8.0.50727.762 (SP.050727-7600).

// simple classes to test enable_if_c
    class Type,
    class Enabler = void>
struct BaseC
    static bool const value = false;

template<class Type>
struct BaseC<
    typename enable_if_c<is_integral<Type>::value >::type>
    static bool const value = true;

template<class Type>
struct DerivedC : BaseC<Type>

// actual tests
void test_c()
    BOOST_STATIC_ASSERT(BaseC<short>::value == true); // fine
    BOOST_STATIC_ASSERT(DerivedC<short>::value == true); // fine

    BOOST_STATIC_ASSERT(DerivedC<int>::value == true); // fails here
    BOOST_STATIC_ASSERT(BaseC<int>::value == true); // fails here

As you've probably noticed, it only fails if DerivedC got instantiated
before BaseC, with the same integral template argument.

Am I doing anything wrong here or is this a compiler bug?

Source code available here:

VC8 solution available here:

Compiles on g++ 4.1.2 with Boost 1.33.1
Fails on VC8 with Boost 1.34.1 and 1.33.0


Boost list run by bdawes at, gregod at, cpdaniel at, john at