I want to get into more template meta-programming. I know that SFINAE stands for “substitution failure is not an error.” But can someone show me a good use for SFINAE?
Share
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.
Heres one example (from here):
When
IsClassT<int>::Yesis evaluated, 0 cannot be converted toint int::*because int is not a class, so it can’t have a member pointer. If SFINAE didn’t exist, then you would get a compiler error, something like ‘0 cannot be converted to member pointer for non-class type int’. Instead, it just uses the...form which returns Two, and thus evaluates to false, int is not a class type.