Boost logo

Boost :

From: Markus Schöpflin (markus.schoepflin_at_[hidden])
Date: 2002-11-21 04:06:54


Gennadiy Rozental wrote:

>>1. Just document it. Not so good, IMHO.
>>
>> 2. Document the special case and add a check for NULL pointers
>> before calling strcmp().
>>
>> 3. Remove the special case alltogether. After all, I might want
>> to check that the pointers are equal and not the string they
>> point to. This might be the best solution, but breaks backward
>> compatibility.
>
> In majority of the cases when user is comparing two character
> pointers he need namely "string comparison". Requiring to cast both
> sides to std::string is a big burden IMO. So I would choose
> solution 2.

Actually I was hoping you would choose option 3. :-) For me, option 2
just doesn't feel right. And I think it's not in the spirit of the
standard, either. (Implicit conversion from char * to string doesn't
exist, a char * is just a pointer.) I would classify this as
"suprising behaviour" which should be avoided wherever possible.

But you're the one to decide and if you go for option 2 please add a
big red warning to the docs.

Markus


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