[C++] Item 2: Understand auto type deduction
By 기술 노트 | 2017년 9월 20일 |
auto type deduction이 곧 template type deduction임 template<typename T>void f(ParamType param); f(expr); // compiler는 expr에서 T의 형식과 ParamType을 추론(deduction)함 auto와 template의 T는 동일한 역할을 수행변수의 형식 지정자는 ParamType과 동일한 역할 수행 auto x = 27; // x의 형식 지정자는 그냥 auto 자체 const auto cx = x; // 형식 지정자(type specifier)는 const auto const auto& rx = x; // const auto&가 type specifier templat