Skip to content

Instantly share code, notes, and snippets.

@swkwon
Last active November 27, 2017 07:41
Show Gist options
  • Save swkwon/5c8c1eda768dadae37418a2f1211cc63 to your computer and use it in GitHub Desktop.
Save swkwon/5c8c1eda768dadae37418a2f1211cc63 to your computer and use it in GitHub Desktop.
decltype type deduction
// ----------------------------------
// example 1
const int i = 0; // decltype(i) is const int
bool f(const Widget& w); // decltype(w) is const Widget&
// decltype(f) is bool(const Widget&)
struct Point {
int x, y; // decltype(Point::x) is int
} // decltype(Point::y) is int
Widget w; // decltype(w) is Widget
std::vector<int> v; // decltype(v) is std::vector<int>
// decltype(v[0]) is int&
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment