For example
template <typename T>
T foo(){ ... }
where T can only be a floating point type, that is float / double / long double
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It’s completely standard SFINAE; we enable on the return type. If T is not a floating point type,
std::is_floating_point<T>::valuewill befalseandstd::enable_if<false, T>does not provide atypetypedef, which causes the function to not be compilable.For information on these standard library classes see http://en.cppreference.com/w/cpp/types.