Auto was a keyword that C++ "inherited" from C and had been around for a long time but was almost never used because there were only two possibilities: it wasn't allowed or it was assumed by default.
C++11 introduced the usage of auto to denote an inferred type.
Similarly to how template type deduction works for function templates, auto x = initializer deduces the type of x from the type of initializer.
Consider the following function template:
template<class T>
int whatever(T t) {
...READ MORE
Jun 21, 2022
in C++
by
Damon
• 4,960 points
•
651 views