forked from boostorg/container_hash
Move std::complex support to hash.hpp
This commit is contained in:
@@ -21,7 +21,6 @@
|
||||
#include <boost/container_hash/hash.hpp>
|
||||
#include <boost/core/enable_if.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <complex>
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_HDR_TUPLE)
|
||||
# include <tuple>
|
||||
@@ -36,9 +35,6 @@ namespace boost
|
||||
template <class A, class B>
|
||||
std::size_t hash_value(std::pair<A, B> const&);
|
||||
|
||||
template <class T>
|
||||
std::size_t hash_value(std::complex<T> const&);
|
||||
|
||||
template <class A, class B>
|
||||
std::size_t hash_value(std::pair<A, B> const& v)
|
||||
{
|
||||
@@ -48,15 +44,6 @@ namespace boost
|
||||
return seed;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
std::size_t hash_value(std::complex<T> const& v)
|
||||
{
|
||||
boost::hash<T> hasher;
|
||||
std::size_t seed = hasher(v.imag());
|
||||
seed ^= hasher(v.real()) + (seed<<6) + (seed>>2);
|
||||
return seed;
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_HDR_TUPLE)
|
||||
namespace hash_detail {
|
||||
template <std::size_t I, typename T>
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <iterator>
|
||||
#include <string>
|
||||
#include <complex>
|
||||
#include <climits>
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_HDR_TYPEINDEX)
|
||||
@@ -153,6 +154,19 @@ namespace boost
|
||||
return boost::hash_range( x, x + N );
|
||||
}
|
||||
|
||||
// complex
|
||||
|
||||
template <class T>
|
||||
std::size_t hash_value( std::complex<T> const& v )
|
||||
{
|
||||
std::size_t seed = 0;
|
||||
|
||||
boost::hash_combine( seed, v.real() );
|
||||
boost::hash_combine( seed, v.imag() );
|
||||
|
||||
return seed;
|
||||
}
|
||||
|
||||
// ranges (list, set, deque...)
|
||||
|
||||
template <typename T>
|
||||
|
||||
Reference in New Issue
Block a user