//////////////////////////////////////// // test2 -- uses boost::enable_if<> // and boost::is_convertible<> //////////////////////////////////////// #include #include #include using namespace std; struct Foo { Foo() {} Foo(Foo const & f) { cout << "Copy Constructor." << endl; } template Foo(T const & src, typename boost::enable_if< boost::is_convertible, void >::type * dummy = 0) { cout << "Convertible." << endl; } template Foo(T const & src, typename boost::disable_if< boost::is_convertible, void >::type * dummy = 0) { cout << "Not Convertible." << endl; } }; int main() { Foo f; Foo f2(f); Foo f3(1); return 0; };