Skip to content

Instantly share code, notes, and snippets.

@meshell
Created February 22, 2016 21:37
Show Gist options
  • Save meshell/5154fb06b69c5150385a to your computer and use it in GitHub Desktop.
Save meshell/5154fb06b69c5150385a to your computer and use it in GitHub Desktop.
// Classic C++ declaration order // Modern C++ style
const char* s = "Hello"; auto s = "Hello";
widget w = get_widget(); auto w = get_widget();
employee e{ empid }; auto e = employee{ empid };
widget w{ 12, 34 }; auto w = widget{ 12, 34 };
unique_ptr<widget> w auto w = make_unique<widget>();
= make_unique<widget>();
int x = 42; auto x = 42;
float x = 42.; auto x = 42.f;
unsigned long x = 42; auto x = 42ul;
std::string x = "42"; auto x = "42"s; // C++14
chrono::nanoseconds x{ 42 }; auto x = 42ns; // C++14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment