That is not true due to the arcane details of how overload resolution works. However, it is possible to observe if you carefully craft your overload set:
Is this special for string literals, or is it true for any array? I completely expected meow("string literal") to output meow(const char (& arr)[N]) string literal.
It’s true for any array. The issue is that overloading values and references can behave unintuitively, even if you know about decay. The hiss() example shows that the template tiebreaker is even involved. This is one of the reasons why I say that overload resolution needs to be treated with care - it works well if you know how to avoid creating complicated scenarios.
13
u/STL MSVC STL Dev Dec 08 '18
String literals aren't pointers - they are arrays that can decay to pointers.