diff options
-rw-r--r-- | libstdc++-v3/ChangeLog | 8 | ||||
-rw-r--r-- | libstdc++-v3/docs/html/ext/howto.html | 6 | ||||
-rw-r--r-- | libstdc++-v3/include/std/std_bitset.h | 22 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/23_containers/bitset/to_string/1.cc | 53 |
4 files changed, 83 insertions, 6 deletions
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 <pcarlini@suse.de> + + 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 <pcarlini@suse.de> * 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 @@ <dd>Replace "new" with "::new". </dd> + <dt><a href="lwg-active.html#434">434</a>: + <em>bitset::to_string() hard to use</em> + </dt> + <dd>Add three overloads, taking fewer template arguments. + </dd> + <dt><a href="lwg-active.html#453">453</a>: <em>basic_stringbuf::seekoff need not always fail for an empty stream</em> </dt> 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<char,char_traits<char>,allocator<char> >(); - * @endcode */ template<class _CharT, class _Traits, class _Alloc> 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<class _CharT, class _Traits> + basic_string<_CharT, _Traits, allocator<_CharT> > + to_string() const + { return to_string<_CharT, _Traits, allocator<_CharT> >(); } + + template<class _CharT> + basic_string<_CharT, char_traits<_CharT>, allocator<_CharT> > + to_string() const + { return to_string<_CharT, char_traits<_CharT>, allocator<_CharT> >(); } + + basic_string<char, char_traits<char>, allocator<char> > + to_string() const + { return to_string<char, char_traits<char>, allocator<char> >(); } + // Helper functions for string operations. template<class _CharT, class _Traits, class _Alloc> 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 <pcarlini@suse.de> + +// 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 <bitset> +#include <testsuite_hooks.h> + +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + bitset<5> b5; + string s0 = b5.to_string<char, char_traits<char>, allocator<char> >(); + VERIFY( s0 == "00000" ); + + // DR 434. bitset::to_string() hard to use. + b5.set(0); + string s1 = b5.to_string<char, char_traits<char> >(); + VERIFY( s1 == "00001" ); + + b5.set(2); + string s2 = b5.to_string<char>(); + VERIFY( s2 == "00101" ); + + b5.set(4); + string s3 = b5.to_string(); + VERIFY( s3 == "10101" ); +} + +int main() +{ + test01(); + return 0; +} |