This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFA] DR 1325 vs cons/2.cc


On 11 October 2010 19:13, Paolo Carlini wrote:
> Hi all, hi Jon,
>
> today I decided to implement the simple resolution of DR 1325, now
> Tentatively Ready, just to be sure we are not doing anything wrong.
> Indeed, everything seems ok a far as our implementation is concerned,
> besides the existing testcase cons/2.cc, devised by Jon to test that the
> old constructor taking a const char* was actually used when appropriate
> and preferred to the one taking a basic_string via a conversion. Now it
> doesn't pass anymore: the constructor taking an unsigned long long gets
> in the way, we get:
>
> 2.cc:36:23: error: invalid conversion from ‘const char*’ to ‘long long
> unsigned int’ [-fpermissive]
> .../include/c++/4.6.0/bitset:807:7: error: initializing argument 1 of
> ‘std::bitset<_Nb>::bitset(long long unsigned int) [with long unsigned
> int _Nb = 32ul]’ [-fpermissive]
>
> For your convenience I'm attaching 2.cc here together with my draft patch.
>
> Are we Ok with the behavior of the new set of constructors? Can we
> safely remove 2.cc or replace it by a slightly different one? Note, the
> constructor taking an unsigned long long would be actually constexpr,
> but I don't *think* that would change anything...

Hmm, that test was pretty contrived - that particular code isn't
necessarily realistic or required to work. It could be removed,
however this change would still test the same thing, while allowing
the template arguments to be deduced and call the new constructor:

Index: testsuite/23_containers/bitset/cons/2.cc
===================================================================
--- testsuite/23_containers/bitset/cons/2.cc    (revision 165193)
+++ testsuite/23_containers/bitset/cons/2.cc    (working copy)
@@ -33,7 +33,7 @@ test01()

   X x;
   std::string s(x);
-  std::bitset<32> b1(x);
+  std::bitset<32> b1(static_cast<const char*>(x));
   std::bitset<32> b2(s);
   VERIFY( b1 == b2 );
 }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]