Hi all,
I am playing around with enable_if and I want to create a constructor switch.
The code is the following:
------------------------------------------------
struct NullType{};
struct TestType{};
struct NonNull{};
template
struct TemplateStruct
{
TemplateStruct(int i, typename boost::enable_if, void* >::type dummy = 0)
{
std::cout << "One Param == " << i << std::endl;
}
TemplateStruct(int i, int j, typename
boost::disable_if, void* >::type dummy =
0)
{
std::cout << "Two Param == " << i << "," << j << std::endl;
}
};
int main(int /*argc*/, char**)
{
TemplateStruct<TestType>(1);
TemplateStruct(1,2);
return 0;
}
-------------------------------------
I want that the first Ctor is only available when a NullType is passed
in and if not that the second one is available but not the first.
I don't want to do a class specialization because the class is rather
big and extracting all the methods to a common class would be
difficult.
So how can I reuse the template parameter U for the Ctors enable_if?
Or is this simply not possible?
Regards,
Michael