diff options
| author | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-03-02 14:08:52 +0000 |
|---|---|---|
| committer | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-03-02 14:08:52 +0000 |
| commit | b6c27c1023b73cddc9b714d8fec6f5265d1d07a6 (patch) | |
| tree | e23eda74f735f0342e9ef1bbfc135a5698e27b00 /libstdc++-v3/include/std/bitset | |
| parent | 348893f5a1f7f665f30cb322456309907fa4485d (diff) | |
| download | ppe42-gcc-b6c27c1023b73cddc9b714d8fec6f5265d1d07a6.tar.gz ppe42-gcc-b6c27c1023b73cddc9b714d8fec6f5265d1d07a6.zip | |
2010-03-02 Paolo Carlini <paolo.carlini@oracle.com>
* include/std/bitset (_Base_bitset<>::_M_getdata()): Add.
(hash<_GLIBCXX_STD_D::bitset<_Nb>>): Add, use the latter.
* include/debug/bitset (hash<std::__debug::bitset<_Nb>>): Add.
* include/profile/bitset (hash<std::__profile::bitset<_Nb>>): Likewise.
* testsuite/23_containers/bitset/hash/1.cc: New.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@157165 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/include/std/bitset')
| -rw-r--r-- | libstdc++-v3/include/std/bitset | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/libstdc++-v3/include/std/bitset b/libstdc++-v3/include/std/bitset index 9101e6797ea..23a2e157c01 100644 --- a/libstdc++-v3/include/std/bitset +++ b/libstdc++-v3/include/std/bitset @@ -114,6 +114,12 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) _M_getword(size_t __pos) const { return _M_w[_S_whichword(__pos)]; } +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + const char* + _M_getdata() const + { return reinterpret_cast<const char*>(_M_w); } +#endif + _WordT& _M_hiword() { return _M_w[_Nw - 1]; } @@ -399,6 +405,12 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) _M_getword(size_t) const { return _M_w; } +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + const char* + _M_getdata() const + { return reinterpret_cast<const char*>(&_M_w); } +#endif + _WordT& _M_hiword() { return _M_w; } @@ -540,6 +552,12 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) return *new _WordT; } +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + const char* + _M_getdata() const + { return reinterpret_cast<const char*>(&_M_getword(0)); } +#endif + _WordT _M_hiword() const { return 0; } @@ -708,6 +726,10 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) _S_do_sanitize(this->_M_hiword()); } +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + template<typename> friend class hash; +#endif + public: /** * This encapsulates the concept of a single bit. An instance of this @@ -1470,6 +1492,25 @@ _GLIBCXX_END_NESTED_NAMESPACE #undef _GLIBCXX_BITSET_WORDS #undef _GLIBCXX_BITSET_BITS_PER_WORD +#ifdef __GXX_EXPERIMENTAL_CXX0X__ +namespace std +{ + // DR 1182. + /// std::hash specialization for bitset. + template<size_t _Nb> + struct hash<_GLIBCXX_STD_D::bitset<_Nb>> + : public std::unary_function<_GLIBCXX_STD_D::bitset<_Nb>, size_t> + { + size_t + operator()(const _GLIBCXX_STD_D::bitset<_Nb>& __b) const + { + const size_t __size = (_Nb + __CHAR_BIT__ - 1) / __CHAR_BIT__; + return std::_Fnv_hash::hash(__b._M_getdata(), __size); + } + }; +} +#endif // __GXX_EXPERIMENTAL_CXX0X__ + #ifdef _GLIBCXX_DEBUG # include <debug/bitset> #endif |

