Understanding how enable_if works.

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
begin 666 main.cpp
M(VEN8VQU9&4@/&)O;W-T+W5T:6QI='DO96YA8FQE7VEF+FAP<#X-"B-I;F-L
M=61E(#QI;W-T

"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
participants (2)
-
David Abrahams
-
Michael Marcin