auto vs decltype

Back

int x;
const int& crx = x;

typedef decltype(x) type_x;
// Type is int
type_x a1 = 10;
// Type is int
auto a2 = x;

typedef decltype(crx) type_crx;
// Type is const int&
type_crx b1 = 10;
// Type is int
auto b2 = crx

Reference