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] | |
Also, bitset has a unsigned long -> unsigned long long ctor replacemens and a new to_ullong() new accessor pending.
Attachment:
CL_bitset_0x
Description: video/flv
Index: include/std/bitset
===================================================================
--- include/std/bitset (revision 155379)
+++ include/std/bitset (working copy)
@@ -798,6 +798,27 @@
_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()
+ {
+ size_t __len = 0;
+ if (__str)
+ {
+ const size_t __len = __builtin_strlen(__str);
+ _M_copy_from_ptr<char,std::char_traits<char>>
+ (__str, __len, 0, __len, '0', '1');
+ }
+ }
+#endif // __GXX_EXPERIMENTAL_CXX0X__
+
// 23.3.5.2 bitset operations:
//@{
/**
Index: testsuite/23_containers/bitset/cons/2.cc
===================================================================
--- testsuite/23_containers/bitset/cons/2.cc (revision 0)
+++ testsuite/23_containers/bitset/cons/2.cc (revision 0)
@@ -0,0 +1,59 @@
+// { dg-options "-std=gnu++0x" }
+
+// 2009-12-16 emsr
+
+// 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/>.
+
+// 23.3.7.1 bitset char * constructor.
+
+#include <bitset>
+#include <algorithm> // std::reverse
+#include <stdexcept>
+#include <cstring> // std::str*
+#include <testsuite_hooks.h>
+
+bool test01(void)
+{
+ bool test __attribute__((unused)) = true;
+
+ const size_t n1 = 128;
+ const char * str01 = "010101000011";
+ const int sz = std::strlen(str01);
+ char str02[sz + 1];
+ std::strcpy(str02, " ");
+ try {
+ std::bitset<n1> bit01(str01);
+ for (int i = 0; i < sz; ++i)
+ str02[i] = (bit01.test(i) ? '1' : '0');
+ std::reverse(str02, str02 + std::strlen(str02));
+ VERIFY( std::strcmp(str02, str01) == 0 );
+ }
+ catch(std::invalid_argument& fail) {
+ VERIFY( false );
+ }
+ catch(...) {
+ VERIFY( false );
+ }
+ return test;
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |