C++11 - explain SFINAE with example of enable_if

less than 1 minute read

1
2
3
4
template <boolB, typename T>
class enable_if {};
template <typename T>
class enable_if<true, T> {typedef T type};

Above code will be only generated by compiler only if the first boolean type is true, if not code generation will not happen due to the rule of SFINAE.