This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: New const char* ctor for C++-0x
2009/12/23 Jonathan Wakely:
> 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?
e.g.
#include <bitset>
struct X {
operator const char* () { return "10101010"; }
};
int main()
{
X x;
std::string s(x);
std::bitset<32> b1(x);
std::bitset<32> b2(s);
VERIFY( b1 == b2 );
}
With your patch applied this passes in c++0x mode, but not otherwise.