From: paolo Date: Tue, 2 Mar 2010 21:48:20 +0000 (+0000) Subject: 2010-03-02 Paolo Carlini X-Git-Url: http://git.sourceforge.jp/view?a=commitdiff_plain;h=19aed4e149d3143d422fbab0fe78547ea11ec006;p=pf3gnuchains%2Fgcc-fork.git 2010-03-02 Paolo Carlini * include/bits/stl_bvector.h (hash>:: operator()(const vector&)): Move definition... * include/bits/vector.tcc: ... here. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@157178 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/libstdc++-v3/include/bits/stl_bvector.h b/libstdc++-v3/include/bits/stl_bvector.h index c7a4acdc084..db81761ca7d 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& __b) const; }; - template - size_t - hash<_GLIBCXX_STD_D::vector>:: - operator()(const _GLIBCXX_STD_D::vector& __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(__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(&__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 8f674931476..984f83f3c9e 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 + size_t + hash<_GLIBCXX_STD_D::vector>:: + operator()(const _GLIBCXX_STD_D::vector& __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(__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(&__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 */