Commit 14492f0b by Paolo Carlini Committed by Paolo Carlini

DR 434.

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.

From-SVN: r90854
parent 410d3bba
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> 2004-11-17 Paolo Carlini <pcarlini@suse.de>
* include/bits/istream.tcc (getline(basic_istream<>&, basic_string<>&, * include/bits/istream.tcc (getline(basic_istream<>&, basic_string<>&,
......
...@@ -497,6 +497,12 @@ ...@@ -497,6 +497,12 @@
<dd>Replace &quot;new&quot; with &quot;::new&quot;. <dd>Replace &quot;new&quot; with &quot;::new&quot;.
</dd> </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>: <dt><a href="lwg-active.html#453">453</a>:
<em>basic_stringbuf::seekoff need not always fail for an empty stream</em> <em>basic_stringbuf::seekoff need not always fail for an empty stream</em>
</dt> </dt>
......
...@@ -1013,12 +1013,6 @@ namespace _GLIBCXX_STD ...@@ -1013,12 +1013,6 @@ namespace _GLIBCXX_STD
* Note the ordering of the bits: decreasing character positions * Note the ordering of the bits: decreasing character positions
* correspond to increasing bit positions (see the main class notes for * correspond to increasing bit positions (see the main class notes for
* an example). * 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> template<class _CharT, class _Traits, class _Alloc>
basic_string<_CharT, _Traits, _Alloc> basic_string<_CharT, _Traits, _Alloc>
...@@ -1029,6 +1023,22 @@ namespace _GLIBCXX_STD ...@@ -1029,6 +1023,22 @@ namespace _GLIBCXX_STD
return __result; 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. // Helper functions for string operations.
template<class _CharT, class _Traits, class _Alloc> template<class _CharT, class _Traits, class _Alloc>
void void
......
// 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;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment