summaryrefslogtreecommitdiff
path: root/libstdc++-v3
diff options
context:
space:
mode:
authorpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2009-12-24 18:12:02 +0000
committerpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2009-12-24 18:12:02 +0000
commit3379a5412a1429cfe4c6806dd496ac2ba04e9bdc (patch)
treee03de1e9b02147e3164675b91b695f4038290978 /libstdc++-v3
parentd122acaf684ecc89723441b04f5ff2bb54e59ef3 (diff)
downloadgcc-3379a5412a1429cfe4c6806dd496ac2ba04e9bdc.tar.gz
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@155458 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3')
-rw-r--r--libstdc++-v3/ChangeLog10
-rw-r--r--libstdc++-v3/include/std/bitset20
-rw-r--r--libstdc++-v3/testsuite/23_containers/bitset/cons/2.cc46
3 files changed, 76 insertions, 0 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index ad2d892c83a..333a51f7d14 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -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
diff --git a/libstdc++-v3/include/std/bitset b/libstdc++-v3/include/std/bitset
index 131fe56de2d..3aee5c08974 100644
--- a/libstdc++-v3/include/std/bitset
+++ b/libstdc++-v3/include/std/bitset
@@ -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:
//@{
/**
diff --git a/libstdc++-v3/testsuite/23_containers/bitset/cons/2.cc b/libstdc++-v3/testsuite/23_containers/bitset/cons/2.cc
new file mode 100644
index 00000000000..a1b9c649c9d
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/bitset/cons/2.cc
@@ -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;
+}