#include <iostream>
#include <type_traits>
class CL
{
public:
CL(){}
CL( int ) = delete;
};
template < class T >
class Creator
{
public:
template< std::enable_if_t< std::is_constructible<T, int>::value, int > = 0 >
static T* Create( int arg ) // 1
{
return new T( arg );
}
template< std::enable_if_t< std::is_default_constructible<T>::value && !std::is_constructible<T, int>::value, int > = 0 >
static T* Create( int arg ) // 2
{
return new T();
}
};
int main()
{
Creator<CL>::Create( 2 );
}
Here I give error that the first Create function can't deduce template argument, but then I commented it, the second overload is works fine. Why SFINAE doesn't work on first overload?