diff options
-rw-r--r-- | libstdc++-v3/include/bits/stl_bvector.h | 36 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/vector.tcc | 46 |
2 files changed, 45 insertions, 37 deletions
diff --git a/libstdc++-v3/include/bits/stl_bvector.h b/libstdc++-v3/include/bits/stl_bvector.h index c7a4acd..db81761 100644 --- a/libstdc++-v3/include/bits/stl_bvector.h +++ b/libstdc++-v3/include/bits/stl_bvector.h @@ -1044,42 +1044,6 @@ _GLIBCXX_BEGIN_NAMESPACE(std) operator()(const _GLIBCXX_STD_D::vector<bool, _Alloc>& __b) const; }; - template<typename _Alloc> - size_t - hash<_GLIBCXX_STD_D::vector<bool, _Alloc>>:: - operator()(const _GLIBCXX_STD_D::vector<bool, _Alloc>& __b) const - { - size_t __hash = 0; - using _GLIBCXX_STD_D::_S_word_bit; - using _GLIBCXX_STD_D::_Bit_type; - - const size_t __words = __b.size() / _S_word_bit; - if (__words) - { - const char* __data - = reinterpret_cast<const char*>(__b._M_impl._M_start._M_p); - const size_t __size = __words * sizeof(_Bit_type); - __hash = std::_Fnv_hash::hash(__data, __size); - } - - const size_t __extrabits = __b.size() % _S_word_bit; - if (__extrabits) - { - _Bit_type __hiword = *__b._M_impl._M_finish._M_p; - __hiword &= ~((~static_cast<_Bit_type>(0)) << __extrabits); - - const char* __data = reinterpret_cast<const char*>(&__hiword); - const size_t __size - = (__extrabits + __CHAR_BIT__ - 1) / __CHAR_BIT__; - if (__words) - __hash = std::_Fnv_hash::hash(__data, __size, __hash); - else - __hash = std::_Fnv_hash::hash(__data, __size); - } - - return __hash; - } - _GLIBCXX_END_NAMESPACE #endif // __GXX_EXPERIMENTAL_CXX0X__ diff --git a/libstdc++-v3/include/bits/vector.tcc b/libstdc++-v3/include/bits/vector.tcc index 8f67493..984f83f 100644 --- a/libstdc++-v3/include/bits/vector.tcc +++ b/libstdc++-v3/include/bits/vector.tcc @@ -1,6 +1,6 @@ // Vector implementation (out of line) -*- C++ -*- -// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -678,4 +678,48 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) _GLIBCXX_END_NESTED_NAMESPACE +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + +_GLIBCXX_BEGIN_NAMESPACE(std) + + template<typename _Alloc> + size_t + hash<_GLIBCXX_STD_D::vector<bool, _Alloc>>:: + operator()(const _GLIBCXX_STD_D::vector<bool, _Alloc>& __b) const + { + size_t __hash = 0; + using _GLIBCXX_STD_D::_S_word_bit; + using _GLIBCXX_STD_D::_Bit_type; + + const size_t __words = __b.size() / _S_word_bit; + if (__words) + { + const char* __data + = reinterpret_cast<const char*>(__b._M_impl._M_start._M_p); + const size_t __size = __words * sizeof(_Bit_type); + __hash = std::_Fnv_hash::hash(__data, __size); + } + + const size_t __extrabits = __b.size() % _S_word_bit; + if (__extrabits) + { + _Bit_type __hiword = *__b._M_impl._M_finish._M_p; + __hiword &= ~((~static_cast<_Bit_type>(0)) << __extrabits); + + const char* __data = reinterpret_cast<const char*>(&__hiword); + const size_t __size + = (__extrabits + __CHAR_BIT__ - 1) / __CHAR_BIT__; + if (__words) + __hash = std::_Fnv_hash::hash(__data, __size, __hash); + else + __hash = std::_Fnv_hash::hash(__data, __size); + } + + return __hash; + } + +_GLIBCXX_END_NAMESPACE + +#endif // __GXX_EXPERIMENTAL_CXX0X__ + #endif /* _VECTOR_TCC */ |