
On Dec 19, 2010, at 4:43 PM, Jeffrey Lee Hellrung, Jr. wrote:
The second call to bar should extract the length at compile time, e.g.
template <size_t length> void bar(const char (&data)[length]) {...}
The problem is that in the presence of the first variant (void bar(const char*)) the second variant does not get called.
-Jochen
In addition to Dave's solution, it looks like if your overloads look like
void bar(char const *&); // note the & template< std::size_t N > void bar(char const (&)[N]);
then the latter will be selected when passed a string literal. Seems to work on MSVC9 anyway...
The Sun Solaris compiler doesn't seem to handle the "char const (&)[N]" syntax. I had to work around it in Boost.Array (look in array.hpp starting about line 349) Just a data point for you. -- Marshall