Skip to content

Instantly share code, notes, and snippets.

@yohhoy
Created August 17, 2020 06:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yohhoy/7b63eafcc42e078f34294857698adfd9 to your computer and use it in GitHub Desktop.
Save yohhoy/7b63eafcc42e078f34294857698adfd9 to your computer and use it in GitHub Desktop.
#include <type_traits>
int main() {
int x = 42;
static_assert(std::is_same_v<decltype( x ), int>);
static_assert(std::is_same_v<decltype((x)), int&>);
int (y) = 42; // redundant parentheses
static_assert(std::is_same_v<decltype( y ), int>);
static_assert(std::is_same_v<decltype((y)), int&>);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment