Hi there, I'm having a problem with using enable_if. For the sake of
simplicity I have created the following test code which compiles fine.
#include <string>
#include
#include
using namespace std;
using namespace boost;
struct reader {};
template< typename String > struct is_string : public mpl::false_ {};
template<> struct is_stringstd::string : public mpl::true_ {};
template< typename Device > struct is_device : public mpl::false_ {};
template<> struct is_device<reader> : public mpl::true_ {};
template< typename String>
struct enable_if_helper
{
typedef typename enable_if< typename is_string< String >::type >::type type;
};
template<typename Device >
void
foo( typename enable_if< typename is_device<Device>::type >::type* ptr = 0 )
{}
template<typename String>
void foo( typename enable_if< typename is_string<String>::type
::type* ptr = 0 )
{ foo<reader>(); }
int main(int argc, _TCHAR* argv[])
{
foostd::string();
return 0;
}
If I changed the string foo() interface to use the enable_if_helper
the code doesn't compile anymore. Why is that?
I've changed the foo ( with the string template parameter ) to the following:
template<typename String>
void foo( typename enable_if_helper< String >::type* ptr = 0 )
{ foo<reader>(); }
Anyone can help me out here? I'm using Visual Studio 8.
Thanks,
Christian