Hi there, I'm trying to compile the following code using MSVC 7.1 but
it fails. Using MSVC 8 works which leaves me with the impression that
it might be a compiler bug.
#include
#include
using namespace boost;
template < typename A > struct is_A : public mpl::true_ {};
template < typename B > struct is_B : public mpl::true_ {};
template< typename A >
struct enable_if_A : public enable_if< typename is_A< A >::type > {};
template< typename B >
struct enable_if_B : public enable_if< typename is_B< B >::type > {};
template < typename One >
inline void foo( typename enable_if_A< One >::type* ptr = 0 ) {}
template < typename One >
inline void foo( typename enable_if_B< One >::type* ptr = 0 ) {}
int _tmain(int argc, _TCHAR* argv[]) { return 0; }
After a while of tinkering I got it to compile when inheriting the
enable_if helper classes from enable_if<...>::type instead of from
enable_if<...>. The following works:
#include
#include
using namespace boost;
template < typename A > struct is_A : public mpl::true_ {};
template < typename B > struct is_B : public mpl::true_ {};
template< typename A >
struct enable_if_A : public enable_if< typename is_A< A >::type >::type {};
template< typename B >
struct enable_if_B : public enable_if< typename is_B< B >::type >::type {};
template < typename One >
inline void foo( typename enable_if_A< One >* ptr = 0 ) {}
template < typename One >
inline void foo( typename enable_if_B< One >* ptr = 0 ) {}
int _tmain(int argc, _TCHAR* argv[]) { return 0; }
Is that a known issue with MSVC 7.1? Or is it always better to inherit
from enable_if<...>::type?
Regards,
Christian