aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.6/libstdc++-v3/include/std/bitset
diff options
context:
space:
mode:
Diffstat (limited to 'gcc-4.6/libstdc++-v3/include/std/bitset')
-rw-r--r--gcc-4.6/libstdc++-v3/include/std/bitset29
1 files changed, 25 insertions, 4 deletions
diff --git a/gcc-4.6/libstdc++-v3/include/std/bitset b/gcc-4.6/libstdc++-v3/include/std/bitset
index e0e8f13..ee771be 100644
--- a/gcc-4.6/libstdc++-v3/include/std/bitset
+++ b/gcc-4.6/libstdc++-v3/include/std/bitset
@@ -52,11 +52,13 @@
#include <iosfwd>
#include <bits/cxxabi_forced.h>
-#define _GLIBCXX_BITSET_BITS_PER_WORD (__CHAR_BIT__ * sizeof(unsigned long))
+#define _GLIBCXX_BITSET_BITS_PER_WORD (__CHAR_BIT__ * __SIZEOF_LONG__)
#define _GLIBCXX_BITSET_WORDS(__n) \
((__n) / _GLIBCXX_BITSET_BITS_PER_WORD + \
((__n) % _GLIBCXX_BITSET_BITS_PER_WORD == 0 ? 0 : 1))
+#define _GLIBCXX_BITSET_BITS_PER_ULL (__CHAR_BIT__ * __SIZEOF_LONG_LONG__)
+
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_CONTAINER
@@ -654,6 +656,24 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
_S_do_sanitize(_WordT) { }
};
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ template<size_t _Nb, bool = _Nb < _GLIBCXX_BITSET_BITS_PER_ULL>
+ struct _Sanitize_val
+ {
+ static constexpr unsigned long long
+ _S_do_sanitize_val(unsigned long long __val)
+ { return __val; }
+ };
+
+ template<size_t _Nb>
+ struct _Sanitize_val<_Nb, true>
+ {
+ static constexpr unsigned long long
+ _S_do_sanitize_val(unsigned long long __val)
+ { return __val & ~((~static_cast<unsigned long long>(0)) << _Nb); }
+ };
+#endif
+
/**
* @brief The %bitset class represents a @e fixed-size sequence of bits.
*
@@ -819,7 +839,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
/// Initial bits bitwise-copied from a single word (others set to zero).
#ifdef __GXX_EXPERIMENTAL_CXX0X__
constexpr bitset(unsigned long long __val)
- : _Base(__val) { }
+ : _Base(_Sanitize_val<_Nb>::_S_do_sanitize_val(__val)) { }
#else
bitset(unsigned long __val)
: _Base(__val)
@@ -1509,6 +1529,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
#undef _GLIBCXX_BITSET_WORDS
#undef _GLIBCXX_BITSET_BITS_PER_WORD
+#undef _GLIBCXX_BITSET_BITS_PER_ULL
#ifdef __GXX_EXPERIMENTAL_CXX0X__
@@ -1525,7 +1546,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
: public __hash_base<size_t, _GLIBCXX_STD_C::bitset<_Nb>>
{
size_t
- operator()(const _GLIBCXX_STD_C::bitset<_Nb>& __b) const
+ operator()(const _GLIBCXX_STD_C::bitset<_Nb>& __b) const noexcept
{
const size_t __clength = (_Nb + __CHAR_BIT__ - 1) / __CHAR_BIT__;
return std::_Hash_impl::hash(__b._M_getdata(), __clength);
@@ -1537,7 +1558,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
: public __hash_base<size_t, _GLIBCXX_STD_C::bitset<0>>
{
size_t
- operator()(const _GLIBCXX_STD_C::bitset<0>&) const
+ operator()(const _GLIBCXX_STD_C::bitset<0>&) const noexcept
{ return 0; }
};