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] | |
On 12/22/2009 05:07 PM, Ed Smith-Rowland wrote:Here is a fixed patch with a simpler test.
OK?Not yet.
+#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>>
Always a space after the comma.
Also, please try to simplify the testcase: I can't believe that in order to test such a small feature we need <algorithm>, <cstring>, etc!
Paolo.
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,43 @@
+// { 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 <testsuite_hooks.h>
+
+bool test01(void)
+{
+ bool test __attribute__((unused)) = true;
+
+ const size_t n1 = 128;
+ const char * str01 = "010101000011";
+ std::bitset<n1> bit01(str01);
+ VERIFY( bit01.to_ulong() == 1347 );
+
+ 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] |