New const char* ctor for C++-0x

Jonathan Wakely jwakely.gcc@gmail.com
Wed Dec 23 15:37:00 GMT 2009


2009/12/23 Ed Smith-Rowland <3dw4rd@verizon.net>:
> Jonathan Wakely wrote:
>>
>> 2009/12/23 Ed Smith-Rowland:
>>
>>>
>>> +  const char * str01 = "010101000011";
>>> +  std::bitset<n1> bit01(str01);
>>>
>>
>> Wouldn't this have passed anyway, without the new constructor?  I
>> believe the point of the new constructor is to avoid the overhead of
>> creating a std::string, but this test doesn't verify that.
>> How about a type with a conversion to char* so that it would take too
>> many conversions to go via the std::string constructor?
>>
>>
>
> I actually tried it under C++-03 by accident and it didn't like illegal
> conversion from pointer to unsigned long.
> It didn't try the string ctor.

Apologies, you're right, it's discussed in LWG issue 116:
http://home.roadrunner.com/~hinnant/issue_review/lwg-closed.html#116

I still think something like my test is better, because the effects of
the new ctor are described in terms of the existing basic_string one.
We can assume that the old ctor works (other tests cover that) and so
can test the new ctor simply by comparing the results with the old
ctor.


>



More information about the Libstdc++ mailing list