Boost logo

Boost :

Subject: Re: [boost] how to distinguish between const char* and const char[N]
From: Jeffrey Lee Hellrung, Jr. (jhellrung_at_[hidden])
Date: 2010-12-19 19:47:58


On 12/19/2010 4:43 PM, Jeffrey Lee Hellrung, Jr. wrote:
> On 12/19/2010 3:21 PM, Jochen Wilhelmy wrote:
>> Hi!
>>
>> is there a (possibly boost powered) way of distinguishing between
>> const char* and const char[N]?
[...]
> 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...
>
> - Jeff

Never mind, forgot a "const" qualifier in the first overload (should be
"char const * const &" to preserve desired behavior), which then doesn't
solve the problem...

Sorry for the spam,

- Jeff


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk