Content deleted Content added
m →Example |
m date audit and style fixes per MOS:NUM and minor clean-up |
||
Line 1:
{{Short description|C++ programming technique}}
'''Substitution failure is not an error''' ('''SFINAE''') is a principle in [[C++]] where an invalid substitution of [[Template (C++)|template]] parameters is not in itself an error. David Vandevoorde first introduced the acronym SFINAE to describe related programming techniques.<ref>{{cite book | last=Vandevoorde | first=David |author2=Nicolai M. Josuttis | title=C++ Templates: The Complete Guide | publisher=Addison-Wesley Professional | year=2002 | isbn=0-201-73484-2}}</ref>
Specifically, when creating a candidate set for [[overload resolution]], some (or all) candidates of that set may be the result of instantiated templates with (potentially deduced) template arguments substituted for the corresponding template parameters. If an error occurs during the substitution of a set of arguments for any given template, the compiler removes the potential overload from the candidate set instead of stopping with a compilation error, provided the substitution error is one the C++ standard grants such treatment.<ref>International Organization for Standardization. "ISO/IEC 14882:2003, Programming languages
==Example==
Line 114 ⟶ 115:
return 0;
}
</syntaxhighlight>
The developers of [[Boost C++ Libraries|Boost]] used SFINAE in boost::enable_if<ref name="enable_if">[http://www.boost.org/doc/libs/release/libs/utility/enable_if.html Boost Enable If]</ref> and in other ways.
Line 123 ⟶ 124:
{{C++ programming language}}
▲{{use dmy dates|date=January 2012}}
[[Category:C++]]
[[Category:Articles with example C++ code]]
|