|
Boost : |
From: Kenneth Ho (ken_at_[hidden])
Date: 2007-10-11 12:47:57
Hi,
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
template<
class Type,
class Enabler = void>
struct BaseC
{
static bool const value = false;
};
template<class Type>
struct BaseC<
Type,
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:
http://fsfoundry.org/tmp/test_enable_if.cpp
VC8 solution available here:
http://fsfoundry.org/tmp/test_enable_if.zip
Compiles on g++ 4.1.2 with Boost 1.33.1
Fails on VC8 with Boost 1.34.1 and 1.33.0
Regards,
ken
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk