aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3
diff options
context:
space:
mode:
Diffstat (limited to 'libstdc++-v3')
-rw-r--r--libstdc++-v3/ChangeLog11
-rw-r--r--libstdc++-v3/docs/html/ext/howto.html6
-rw-r--r--libstdc++-v3/include/debug/bitset4
-rw-r--r--libstdc++-v3/include/std/bitset80
-rw-r--r--libstdc++-v3/testsuite/23_containers/bitset/all/1.cc81
5 files changed, 133 insertions, 49 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index d05dd12..635bb1e 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,5 +1,16 @@
2007-11-23 Paolo Carlini <pcarlini@suse.de>
+ * include/std/bitset (bitset<>::all): Add, per DR 693 [Ready].
+ (_Base_bitset<>::_M_are_all_aux()): Add.
+ * include/debug/bitset (bitset<>::all): Add.
+ * testsuite/23_containers/bitset/all/1.cc: New.
+ * docs/html/ext/howto.html: Add an entry for DR 693.
+
+ * include/std/bitset (bitset<0>::set, reset, flip, test): Remove,
+ not necessary anymore.
+
+2007-11-23 Paolo Carlini <pcarlini@suse.de>
+
* include/bits/stl_list.h (insert(iterator, value_type&&)): Just
forward to emplace.
* include/bits/stl_vector.h (insert(iterator, value_type&&)): Likewise.
diff --git a/libstdc++-v3/docs/html/ext/howto.html b/libstdc++-v3/docs/html/ext/howto.html
index cb0a74e..3171355 100644
--- a/libstdc++-v3/docs/html/ext/howto.html
+++ b/libstdc++-v3/docs/html/ext/howto.html
@@ -639,6 +639,12 @@
<dd>Add the missing operations.
</dd>
+ <dt><a href="lwg-active.html#693">693</a>:
+ <em>std::bitset::all() missing</em>
+ </dt>
+ <dd>Add it, consistently with the discussion.
+ </dd>
+
<dt><a href="lwg-active.html#695">695</a>:
<em>ctype&lt;char&gt;::classic_table() not accessible</em>
</dt>
diff --git a/libstdc++-v3/include/debug/bitset b/libstdc++-v3/include/debug/bitset
index ba67712..db4b3c0 100644
--- a/libstdc++-v3/include/debug/bitset
+++ b/libstdc++-v3/include/debug/bitset
@@ -1,7 +1,6 @@
// Debugging bitset implementation -*- C++ -*-
-// Copyright (C) 2003, 2004, 2005
-// Free Software Foundation, Inc.
+// Copyright (C) 2003, 2004, 2005, 2006, 2007 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
@@ -279,6 +278,7 @@ namespace __debug
{ return _M_base() != __rhs; }
using _Base::test;
+ using _Base::all;
using _Base::any;
using _Base::none;
diff --git a/libstdc++-v3/include/std/bitset b/libstdc++-v3/include/std/bitset
index c9f9111..9a984d03 100644
--- a/libstdc++-v3/include/std/bitset
+++ b/libstdc++-v3/include/std/bitset
@@ -170,21 +170,27 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
_M_is_equal(const _Base_bitset<_Nw>& __x) const
{
for (size_t __i = 0; __i < _Nw; ++__i)
- {
- if (_M_w[__i] != __x._M_w[__i])
- return false;
- }
+ if (_M_w[__i] != __x._M_w[__i])
+ return false;
return true;
}
+ size_t
+ _M_are_all_aux() const
+ {
+ for (size_t __i = 0; __i < _Nw - 1; __i++)
+ if (_M_w[__i] != ~static_cast<_WordT>(0))
+ return 0;
+ return ((_Nw - 1) * _GLIBCXX_BITSET_BITS_PER_WORD
+ + __builtin_popcountl(_M_hiword()));
+ }
+
bool
_M_is_any() const
{
for (size_t __i = 0; __i < _Nw; __i++)
- {
- if (_M_w[__i] != static_cast<_WordT>(0))
- return true;
- }
+ if (_M_w[__i] != static_cast<_WordT>(0))
+ return true;
return false;
}
@@ -412,6 +418,10 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
_M_is_equal(const _Base_bitset<1>& __x) const
{ return _M_w == __x._M_w; }
+ size_t
+ _M_are_all_aux() const
+ { return __builtin_popcountl(_M_w); }
+
bool
_M_is_any() const
{ return _M_w != 0; }
@@ -540,6 +550,10 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
_M_is_equal(const _Base_bitset<0>&) const
{ return true; }
+ size_t
+ _M_are_all_aux() const
+ { return 0; }
+
bool
_M_is_any() const
{ return false; }
@@ -1089,7 +1103,17 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
__throw_out_of_range(__N("bitset::test"));
return _Unchecked_test(__position);
}
-
+
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // DR 693. std::bitset::all() missing.
+ /**
+ * @brief Tests whether all the bits are on.
+ * @return True if all the bits are set.
+ */
+ bool
+ all() const
+ { return this->_M_are_all_aux() == _Nb; }
+
/**
* @brief Tests whether any of the bits are on.
* @return True if at least one bit is set.
@@ -1298,44 +1322,6 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
__x._M_copy_to_string(__tmp);
return __os << __tmp;
}
-
- // Specializations for zero-sized bitsets, to avoid "unsigned comparison
- // with zero" warnings.
- template<>
- inline bitset<0>&
- bitset<0>::
- set(size_t, bool)
- {
- __throw_out_of_range(__N("bitset::set"));
- return *this;
- }
-
- template<>
- inline bitset<0>&
- bitset<0>::
- reset(size_t)
- {
- __throw_out_of_range(__N("bitset::reset"));
- return *this;
- }
-
- template<>
- inline bitset<0>&
- bitset<0>::
- flip(size_t)
- {
- __throw_out_of_range(__N("bitset::flip"));
- return *this;
- }
-
- template<>
- inline bool
- bitset<0>::
- test(size_t) const
- {
- __throw_out_of_range(__N("bitset::test"));
- return false;
- }
//@}
_GLIBCXX_END_NESTED_NAMESPACE
diff --git a/libstdc++-v3/testsuite/23_containers/bitset/all/1.cc b/libstdc++-v3/testsuite/23_containers/bitset/all/1.cc
new file mode 100644
index 0000000..1464510
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/bitset/all/1.cc
@@ -0,0 +1,81 @@
+// 2007-11-23 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 2007 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// 23.3.5.2 bitset members
+
+#include <bitset>
+#include <testsuite_hooks.h>
+
+// DR 693. std::bitset::all() missing.
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::bitset<0> z1;
+ VERIFY( z1.all() );
+ z1.set();
+ VERIFY( z1.all() );
+
+ std::bitset<8> z2;
+ VERIFY( !z2.all() );
+ z2.set();
+ VERIFY( z2.all() );
+
+ std::bitset<16> z3;
+ VERIFY( !z3.all() );
+ z3.set();
+ VERIFY( z3.all() );
+
+ std::bitset<32> z4;
+ VERIFY( !z4.all() );
+ z4.set();
+ VERIFY( z4.all() );
+
+ std::bitset<64> z5;
+ VERIFY( !z5.all() );
+ z5.set();
+ VERIFY( z5.all() );
+
+ std::bitset<96> z6;
+ VERIFY( !z6.all() );
+ z6.set();
+ VERIFY( z6.all() );
+
+ std::bitset<128> z7;
+ VERIFY( !z7.all() );
+ z7.set();
+ VERIFY( z7.all() );
+
+ std::bitset<192> z8;
+ VERIFY( !z8.all() );
+ z8.set();
+ VERIFY( z8.all() );
+
+ std::bitset<1024> z9;
+ VERIFY( !z9.all() );
+ z9.set();
+ VERIFY( z9.all() );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}