3 ms·
Sorry, wasn't checking my HN comments frequently (unlike Reddit there's no little red icon). "meow" is a traditional string literal, whose type is const char [
by StephanTLavavej 12y ago
Sorry, wasn't checking my HN comments frequently (unlike Reddit there's no little red icon).
"meow" is a traditional string literal, whose type is const char [5] (array of 5 const chars). When you say "auto", you get the same deduction as when you pass something to a template foo(T t) taking by value. This triggers "decay", where arrays decay to pointers. Hence auto (and T) is const char *.
"meow"s is a user-defined literal (the Standard Library is a user as far as the compiler is concerned), for which you must include <string> and say "using namespace std::string_literals;" or something equivalent. The specification for UDLs says that this calls operator""s() which returns a std::string by value.
Yep, I'm the video guy. Glad you like them!