auto Type Declarations

auto Type Declarations: Motivation

Much ado about nothing …
vector<MyType>::iterator
  iter = v.begin();
Compiler knows anyway …
auto iter = v.begin();
  • Type Deduction

  • Compiler knows anyway

  • He always knew ⟶ lookup of template specializations

  • ⟶ Same rules apply

auto Type Declarations: Details

Simplest Type Deduction
auto i = 10; // int
cbegin()const_iterator
auto iter = v.cbegin();
const and References
const auto& cref = value;
Arrays are Pointers
int data[42];
// int *no_copy ...
auto no_copy = data;