3.1.1-3.1.4 and 12.5

3 New Language Features

3.1 New C++11 Language Features

3.1.1 Important Minor Syntax Cleanups

Spaces in Template Expressions

vector<list<int> >; // all C++ versions
vector<list<int>>; // C++11 and beyond

No value: nullptr and std::nullptr_t

Use nullptr instead of 0 or NULL

3.1.2 Automatic Type Deduction with auto

auto i; // ERROR, needs to be initialized
auto i = 42; // much better, i is type int
vector<string> v;
auto pos = v.begin(); // pos is type vector<string>::iterator

3.1.3 Uniform Initialization and Initializer Lists

Yup, just do { }

std::vector<std::string> v {"Yo", "wassup", "up", "dog"};

But don't be silly

int gravity {9.8}; // naw son
char identity_crisis{9999}; // what do you think you're doing?
std::vector<int> drop_it_to_the_floor = {1.94, 0.23, 3.23}; // hell no
auto i; // you're not allowed to use c++11 anymo

3.1.4 Range-Based for Loops

for (auto decl : coll) {... }
// in class we learned to pass by reference for optimization, but it may not always work
for (auto &elem : set) {... }

3.1.5 Move Semantics and other stuff

12.5 Bitsets

results matching ""

    No results matching ""