(C++) std::enable\_if
February 24, 2017 · View on GitHub
(C++) std::enable_if
std::enable_if is a C++11 ...
std::enable_if 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' [2].
Examples
Advice
- Distinguish among std::enable_if, static_assert, and =delete [1]
External links
References
- Scott Meyers. C++ And Beyond 2012 session: 'Initial thoughts on Effective C++11'. 2012. 'Distinguish among std::enable_if, static_assert, and =delete'
- cppreference.com its page about std::enable_if: '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.'