summaryrefslogtreecommitdiff
path: root/libstdc++-v3
diff options
context:
space:
mode:
authorpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2011-09-02 13:30:32 +0000
committerpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2011-09-02 13:30:32 +0000
commitdd0eb0dfcbc293149f2096afc434a111b1ed0b90 (patch)
tree739b886e4ff9d7307b764a66396008b4a90f35dd /libstdc++-v3
parentd4e80e2bbf93d1bbd93dfa97ac822efb5c8d5ea8 (diff)
downloadgcc-dd0eb0dfcbc293149f2096afc434a111b1ed0b90.tar.gz
2011-09-02 Paolo Carlini <paolo.carlini@oracle.com>
Marc Glisse <marc.glisse@normalesup.org> * include/std/bitset (_Base_bitset<>::_M_are_all_aux): Remove. (_Base_bitset<>::_M_are_all): Add. (bitset<>::all): Use the latter, improve implementation. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@178473 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3')
-rw-r--r--libstdc++-v3/ChangeLog7
-rw-r--r--libstdc++-v3/include/std/bitset37
2 files changed, 28 insertions, 16 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index bd9850cd43b..cb8361a3347 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,6 +1,13 @@
2011-09-02 Paolo Carlini <paolo.carlini@oracle.com>
Marc Glisse <marc.glisse@normalesup.org>
+ * include/std/bitset (_Base_bitset<>::_M_are_all_aux): Remove.
+ (_Base_bitset<>::_M_are_all): Add.
+ (bitset<>::all): Use the latter, improve implementation.
+
+2011-09-02 Paolo Carlini <paolo.carlini@oracle.com>
+ Marc Glisse <marc.glisse@normalesup.org>
+
PR libstdc++/50268
* include/std/bitset (struct _Sanitize_val): Add.
(bitset<>::bitset(unsigned long long)): Fix.
diff --git a/libstdc++-v3/include/std/bitset b/libstdc++-v3/include/std/bitset
index 648d7ab5fe8..f771bfc0e01 100644
--- a/libstdc++-v3/include/std/bitset
+++ b/libstdc++-v3/include/std/bitset
@@ -185,15 +185,17 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
return true;
}
- size_t
- _M_are_all_aux() const _GLIBCXX_NOEXCEPT
- {
- 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()));
- }
+ template<size_t _Nb>
+ bool
+ _M_are_all() const _GLIBCXX_NOEXCEPT
+ {
+ for (size_t __i = 0; __i < _Nw - 1; __i++)
+ if (_M_w[__i] != ~static_cast<_WordT>(0))
+ return false;
+ return _M_hiword() == (~static_cast<_WordT>(0)
+ >> (_Nw * _GLIBCXX_BITSET_BITS_PER_WORD
+ - _Nb));
+ }
bool
_M_is_any() const _GLIBCXX_NOEXCEPT
@@ -460,9 +462,11 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
_M_is_equal(const _Base_bitset<1>& __x) const _GLIBCXX_NOEXCEPT
{ return _M_w == __x._M_w; }
- size_t
- _M_are_all_aux() const _GLIBCXX_NOEXCEPT
- { return __builtin_popcountl(_M_w); }
+ template<size_t _Nb>
+ bool
+ _M_are_all() const _GLIBCXX_NOEXCEPT
+ { return _M_w == (~static_cast<_WordT>(0)
+ >> (_GLIBCXX_BITSET_BITS_PER_WORD - _Nb)); }
bool
_M_is_any() const _GLIBCXX_NOEXCEPT
@@ -605,9 +609,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
_M_is_equal(const _Base_bitset<0>&) const _GLIBCXX_NOEXCEPT
{ return true; }
- size_t
- _M_are_all_aux() const _GLIBCXX_NOEXCEPT
- { return 0; }
+ template<size_t _Nb>
+ bool
+ _M_are_all() const _GLIBCXX_NOEXCEPT
+ { return true; }
bool
_M_is_any() const _GLIBCXX_NOEXCEPT
@@ -1312,7 +1317,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
*/
bool
all() const _GLIBCXX_NOEXCEPT
- { return this->_M_are_all_aux() == _Nb; }
+ { return this->template _M_are_all<_Nb>(); }
/**
* @brief Tests whether any of the bits are on.