Substitution failure is not an error: Difference between revisions

Content deleted Content added
Undid revision 442187633 by Demonkoryu (talk) K&R indentation is accepted here
m Undid revision 442600324 by 1exec1 (talk) This style conserves vertical space. It's also "accepted here".
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;