effective c++
[EMCpp]Item-5 Prefer Auto to Explicit Type Declarations
· ☕ 4 min read

Despite some pitfalls described in EMCpp item 2 and 6, auto variables are preferred for they must be initialized, are generally immune to type mismatches that can lead to portability or efficiency problems, can ease the process of refactoring, and typically require less typing than variables with explicitly specified types.


[EMCpp]Item-4 Know How to View Deduced Types
· ☕ 3 min read

Deduced types can often be seen using IDE editors, compiler error messages, and the Boost TypeIndex library, but the results of some tools may be neither helpful nor accurate.


[EMCpp]Item-3 Understand Decltype
· ☕ 4 min read

decltype almost always yields the type of a variable or expression without any modifications. For lvalue expressions of type T other than names, decltype always reports a type of T&.


[EMCpp]Item-2 Understand Auto Type Deduction
· ☕ 4 min read

auto type deduction is usually the same as template type deduction, with an exception in the case of braced initializer. Also, in C++14, as a function return type or a lambda parameter, auto implies template type deduction instead of auto type deduction.