From ac7f029a464b1e3557bf2c4f8ae1c97dc93bbd3c Mon Sep 17 00:00:00 2001 From: paolo Date: Thu, 18 Nov 2004 09:52:57 +0000 Subject: [PATCH] 2004-11-18 Paolo Carlini DR 434. bitset::to_string() hard to use [Ready] * include/std/std_bitset.h (to_string): Add three overloads, taking fewer template arguments. * docs/html/ext/howto.html: Add an entry for DR 434. * testsuite/23_containers/bitset/to_string/1.cc: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@90854 138bc75d-0d04-0410-961f-82ee72b054a4 --- libstdc++-v3/ChangeLog | 8 ++++ libstdc++-v3/docs/html/ext/howto.html | 6 +++ libstdc++-v3/include/std/std_bitset.h | 22 ++++++--- .../testsuite/23_containers/bitset/to_string/1.cc | 53 ++++++++++++++++++++++ 4 files changed, 83 insertions(+), 6 deletions(-) create mode 100644 libstdc++-v3/testsuite/23_containers/bitset/to_string/1.cc diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index ab93497..370044a 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,11 @@ +2004-11-18 Paolo Carlini + + DR 434. bitset::to_string() hard to use [Ready] + * include/std/std_bitset.h (to_string): Add three overloads, taking + fewer template arguments. + * docs/html/ext/howto.html: Add an entry for DR 434. + * testsuite/23_containers/bitset/to_string/1.cc: New. + 2004-11-17 Paolo Carlini * include/bits/istream.tcc (getline(basic_istream<>&, basic_string<>&, diff --git a/libstdc++-v3/docs/html/ext/howto.html b/libstdc++-v3/docs/html/ext/howto.html index 5b4a69f..194bc5d 100644 --- a/libstdc++-v3/docs/html/ext/howto.html +++ b/libstdc++-v3/docs/html/ext/howto.html @@ -497,6 +497,12 @@
Replace "new" with "::new".
+
434: + bitset::to_string() hard to use +
+
Add three overloads, taking fewer template arguments. +
+
453: basic_stringbuf::seekoff need not always fail for an empty stream
diff --git a/libstdc++-v3/include/std/std_bitset.h b/libstdc++-v3/include/std/std_bitset.h index 3f131aa..fa17a61 100644 --- a/libstdc++-v3/include/std/std_bitset.h +++ b/libstdc++-v3/include/std/std_bitset.h @@ -1013,12 +1013,6 @@ namespace _GLIBCXX_STD * Note the ordering of the bits: decreasing character positions * correspond to increasing bit positions (see the main class notes for * an example). - * - * Also note that you must specify the string's template parameters - * explicitly. Given a bitset @c bs and a string @s: - * @code - * s = bs.to_string,allocator >(); - * @endcode */ template basic_string<_CharT, _Traits, _Alloc> @@ -1029,6 +1023,22 @@ namespace _GLIBCXX_STD return __result; } + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 434. bitset::to_string() hard to use. + template + basic_string<_CharT, _Traits, allocator<_CharT> > + to_string() const + { return to_string<_CharT, _Traits, allocator<_CharT> >(); } + + template + basic_string<_CharT, char_traits<_CharT>, allocator<_CharT> > + to_string() const + { return to_string<_CharT, char_traits<_CharT>, allocator<_CharT> >(); } + + basic_string, allocator > + to_string() const + { return to_string, allocator >(); } + // Helper functions for string operations. template void diff --git a/libstdc++-v3/testsuite/23_containers/bitset/to_string/1.cc b/libstdc++-v3/testsuite/23_containers/bitset/to_string/1.cc new file mode 100644 index 0000000..8a75512 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/bitset/to_string/1.cc @@ -0,0 +1,53 @@ +// 2004-11-17 Paolo Carlini + +// Copyright (C) 2004 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 23.3.5.2 bitset members + +#include +#include + +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + bitset<5> b5; + string s0 = b5.to_string, allocator >(); + VERIFY( s0 == "00000" ); + + // DR 434. bitset::to_string() hard to use. + b5.set(0); + string s1 = b5.to_string >(); + VERIFY( s1 == "00001" ); + + b5.set(2); + string s2 = b5.to_string(); + VERIFY( s2 == "00101" ); + + b5.set(4); + string s3 = b5.to_string(); + VERIFY( s3 == "10101" ); +} + +int main() +{ + test01(); + return 0; +} -- 2.7.4