std::enable_if (3) - Linux Man Pages
Defined in header <type_traits>
template< bool B, class T = void > (since C++11)
If B is true, std::enable_if has a public member typedef type, equal to T; otherwise, there is no member typedef.
This metafunction is a convenient way to leverage SFINAE to conditionally remove functions from overload_resolution based on type traits and to provide separate function overloads and specializations for different type traits. std::enable_if can be used as an additional function argument (not applicable to operator overloads), as a return type (not applicable to constructors and destructors), or as a class template or function template parameter.
type either T or no such member, depending on the value of B
template< bool B, class T = void > (since C++14)
using enable_if_t = typename enable_if<B,T>::type;
A common mistake is to declare two function templates that differ only in their default template arguments. This is illegal because default template arguments are not part of function template's signature, and declaring two different function templates with the same signature is illegal.
Care should be taken when using enable_if in the type of a template non-type parameter of a namespace-scope function template. Some ABI specifications like the Itanium ABI do not include the instantiation-dependent portions of non-type template parameters in the mangling, meaning that specializations of two distinct function templates might end up with the same mangled name and be erroneously linked together. For example:
The function templates #1 and #3 have different signatures and are distinct templates. Nonetheless, #2 and #4, despite being instantiations of different function templates, have the same mangled name in_the_Itanium_C++_ABI (_Z4funcI1XLi0EEvv), meaning that the linker will erroneously consider them to be the same entity.
// Run this code