be further compacted since "myvec" implements begin/end iterators: for (const auto& x : myvec) This difference grows as the programmer begins to nest containers, though in such cases typedefs are a good way to decrease the amount of code. The type denoted by decltype can be different from the type deduced by auto. #include <vector> int main() { const std::vector<int> v(1); auto a = v[0]; // a has type int decltype(v[0]) b = 1; // b has type const int&, the return type of // std::vector<int>::operator[](size_type) const auto c = 0; // c has type int auto d = c; // d has type int decltype(c) e; // e has type int, the type of the entity named by c decltype((c)) f = c; // f has type int&, because (c) is an lvalue decltype(0) g; // g has type int, because 0 is an rvalue } Range-based for loop C++11 extends the syntax of the for statement to allow for easy iteration over a range of elements: int my_array[5] = {1, 2, 3, 4, 5}; // double the value of each element in my_array: for (int& x : my_array) x *= 2; // similar but also using type inference for array elements for (auto& x : my_array) x *= 2; This form of for, called the “range-based for”, will iterate over each element in the list. It will work for C-style arrays, initializer lists, and any type that has begin() and end() functions defined for it that return iterators. All the standard library containers that have begin/end pairs will work with the range-based for statement. Lambda functions and expressions C++11 provides the ability to create anonymous functions, called lambda functions. These are defined as follows: [](int x, int y) -> int { return x + y; } The return type (-> int in this example) can be omitted as long as all return expressions return the same type. A lambda can optionally be a closure. Alternative function syntax Standard C function declaration syntax was perfectly adequate for the feature set of the C language. As C++ evolved from C, it kept the basic syntax and extended it where needed. However, as C++ grew more complex, it exposed several limits, especially regarding template function declarations. For example, in C++03 this is invalid: template<class Lhs, class Rhs> Ret adding_func(const Lhs &lhs, const Rhs &rhs) {return lhs + rhs;} //Ret must be