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]

[RFA] DR 1325 vs cons/2.cc


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...

Thanks,
Paolo.

////////////////////
// { dg-options "-std=gnu++0x" }

// Copyright (C) 2009 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library.  This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.

// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3.  If not see
// <http://www.gnu.org/licenses/>.

#include <bitset>
#include <string>
#include <testsuite_hooks.h>

struct X
{
  operator const char*() { return "10101010"; }
};

void
test01()
{
  bool test __attribute__((unused)) = true;

  X x;
  std::string s(x);
  std::bitset<32> b1(x);
  std::bitset<32> b2(s);
  VERIFY( b1 == b2 );
}

int
main()
{
  test01();
  return 0;
}

Attachment: patch_dr1325
Description: Text document


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