Last active
December 2, 2015 13:06
-
-
Save disconnect3d/5b0ef102cab7944a3aea to your computer and use it in GitHub Desktop.
"Default initialization trap"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
template <typename T> | |
struct X { | |
T x; | |
}; | |
template <typename T> | |
void foo() { | |
T a{}; | |
T b; | |
T c(); // trap - function declaration | |
cout << a.x << b.x << endl; | |
cout << c.x << endl; // a function doesn't have c.x | |
} | |
int main() { | |
foo<X<int>>(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment