Skip to content

Instantly share code, notes, and snippets.

@disconnect3d
Last active December 2, 2015 13:06
Show Gist options
  • Save disconnect3d/5b0ef102cab7944a3aea to your computer and use it in GitHub Desktop.
Save disconnect3d/5b0ef102cab7944a3aea to your computer and use it in GitHub Desktop.
"Default initialization trap"
#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