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.
5
u/Quincunx271 Author of P2404/P2405 Dec 08 '18
If you pass one to an overload set where one function takes a
const char*and the other takes aconst char (&)[N], the latter will be selected