auto behaves exactly 1 as the output of the template argument. Just like T !
Compare this:
template<typename T> void print_size(T x) { std::cout << sizeof(x) << '\n'; } int main() { print_size("If you timidly approach C++ as just a better C or as an object-oriented language, you are going to miss the point.");
Wherein:
template<typename T> void print_size(const T& x) { std::cout << sizeof(x) << '\n'; } int main() { print_size("If you timidly approach C++ as just a better C or as an object-oriented language, you are going to miss the point.");
1 Not quite, but this is not one of the corner cases.
source share