Item 13: Prefer const_iterators to iterators
Because in C++11 const_iterator is finally usable.
Reading notes of Effective Modern C++, 1st ed.
Because in C++11 const_iterator is finally usable.
Because it is easy to miss the 6 conditions for overriding to occur.
Delete functions replace the private-undefined-function trick and there are some nice tricks that only delete functions can do.
Scoped enums are better because they are scoped, strong-typed, and may be forward-declared out-of-the-box.
Because alias declarations may be templatized but typedefs can’t.
Because 0 and NULL doesn’t work well with function overloads and template type deduction.
Uniform initialization is usually preferred, but it may surprise you when combined with std::initializer_list and constructor overload resolution (and template makes the situation even more frustrating).
General rule: “Invisible” proxy classes don’t play well with auto. Use explicitly typed initializer idiom to work around it.
auto saves typing, prevents incorrect or less-performant (eliminate unnecessary temporary objects) usages, and sometimes is a must.
In additional to IDE support, you may use compiler diagonostics (e.g., use declared but undefined templates).
decltype rules are sometimes preferred in type deduction. Primary use case of decltype: When declaring function templates, make function’s return type depends on its parameter type.
Same as template type deduction, except for std::initializer_list.
Three general cases: 1. Reference or pointer but not universal reference; 2. Universal reference; 3. Neither reference nor pointer. Edge cases: Array arguments and function arguments.
C++11’s most pervasive feature is probably move semantics, and the foundation of it is distinguishing expression that are rvalues from those that are lvalues.