]> gcc.gnu.org Git - gcc.git/commitdiff
[multiple changes]
authorPaolo Carlini <paolo@gcc.gnu.org>
Thu, 24 Dec 2009 18:12:02 +0000 (18:12 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Thu, 24 Dec 2009 18:12:02 +0000 (18:12 +0000)
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

libstdc++-v3/ChangeLog
libstdc++-v3/include/std/bitset
libstdc++-v3/testsuite/23_containers/bitset/cons/2.cc [new file with mode: 0644]

index ad2d892c83aba37414822aa217cfd6d623e262ea..333a51f7d149794e29f243256930af46cdee8269 100644 (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
index 131fe56de2da1629118c1f129d414c39f5a49622..3aee5c08974ceb06cd4a0611b09a92f56e47a085 100644 (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:
       //@{
       /**
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 (file)
index 0000000..a1b9c64
--- /dev/null
@@ -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;
+}
This page took 0.074018 seconds and 5 git commands to generate.