Substitution failure is not an error: Difference between revisions

Content deleted Content added
Nonick (talk | contribs)
m Example: Grammar
Line 87:
}
</source>
 
With the standardisation of the detection idiom and void_t in C++17, the above code can be re-written as follows:
<source>
#include <iostream>
#include <type_traits>
 
template <typename T>
using has_typedef_foobar_t = decltype(T::foobar);
 
struct foo {
using foobar = float;
};
 
int main() {
std::cout << std::boolalpha;
std::cout << std::is_detected<has_typedef_foobar_t, int>::value << std::endl;
std::cout << std::is_detected<has_typedef_foobar_t, int>::value << std::endl;
}
</source>
 
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.