"Michael Marcin"
Hi,
I'm new to boost / generic programming and I'm trying to understand how enable_if works because I don't like using things I don't understand.
I made a simple example which I thought would have the same behavior as using enable_if but doesn't.
I've attached the test could someone take a look and explain why enable_if works and the other doesn't.
Thanks
#include
#include <iostream> namespace TestBroken { template< class T > struct TestTrait { };
template<> struct TestTrait<int> { typedef int enable_type; ^^^ };
template< class T, class Enable = void > struct EnableTest { EnableTest() { std::cout << "Generic Enable Test constructed" << std::endl; } };
It doesn't work because your specialization doesn't match the default. Change the indicated int to void and it should work for you. -- Dave Abrahams Boost Consulting www.boost-consulting.com