[multiple changes]

2009-12-24  Edward Smith-Rowland  <3dw4rd@verizon.net>
	    Paolo Carlini  <paolo.carlini@oracle.com>

	* include/std/bitset (bitset<>::bitset(const char*)): Add.

2009-12-24  Jonathan Wakely  <jwakely.gcc@gmail.com>
	    Edward Smith-Rowland  <3dw4rd@verizon.net>

	* testsuite/23_containers/bitset/cons/2.cc: New.

From-SVN: r155458
This commit is contained in:
Paolo Carlini 2009-12-24 18:12:02 +00:00
parent c5a2375241
commit a1b418cb9f
3 changed files with 76 additions and 0 deletions

View File

@ -1,3 +1,13 @@
2009-12-24 Edward Smith-Rowland <3dw4rd@verizon.net>
Paolo Carlini <paolo.carlini@oracle.com>
* include/std/bitset (bitset<>::bitset(const char*)): Add.
2009-12-24 Jonathan Wakely <jwakely.gcc@gmail.com>
Edward Smith-Rowland <3dw4rd@verizon.net>
* testsuite/23_containers/bitset/cons/2.cc: New.
2009-12-24 Jonathan Wakely <jwakely.gcc@gmail.com>
* include/std/functional (bind): Avoid invalid instantiations

View File

@ -798,6 +798,26 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
_M_copy_from_string(__s, __position, __n, __zero, __one);
}
#ifdef __GXX_EXPERIMENTAL_CXX0X__
/**
* @brief Construct from a string.
* @param str A string of '0' and '1' characters.
* @throw std::invalid_argument If a character appears in the string
* which is neither '0' nor '1'.
*/
explicit
bitset(const char* __str)
: _Base()
{
if (!__str)
__throw_logic_error(__N("bitset::bitset(const char*)"));
const size_t __len = __builtin_strlen(__str);
_M_copy_from_ptr<char, std::char_traits<char>>(__str, __len, 0,
__len, '0', '1');
}
#endif
// 23.3.5.2 bitset operations:
//@{
/**

View File

@ -0,0 +1,46 @@
// { 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;
}