Substitution failure is not an error: Difference between revisions

Content deleted Content added
m Example: Self-consistency
mNo edit summary
Line 7:
 
<source lang="cpp">
struct Test {
{
typedef int type;
};
 
template < typename T >
void f(typename T::type) {} // definition #1
 
template < typename T >
void f(T) {} // definition #2
 
int main() {
{
f<Test>(10); // call #1
f<int>(10); // call #2 without error thanks to SFINAE
Line 35 ⟶ 33:
 
template <typename T>
struct has_typedef_type {
{
// yes and no are guaranteed to have different sizes,
// specifically sizeof(yes) == 1 and sizeof(no) == 2
Line 53 ⟶ 50:
};
 
struct foo {
{
typedef float type;
};
 
int main() {
{
std::cout << std::boolalpha;
std::cout << has_typedef_type<int>::value << std::endl;