mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Add std::hash <std::pair> specialization
This commit is contained in:
@@ -202,6 +202,7 @@
|
||||
<ClInclude Include="..\..\beast\utility\Debug.h" />
|
||||
<ClInclude Include="..\..\beast\utility\EnableIf.h" />
|
||||
<ClInclude Include="..\..\beast\utility\Error.h" />
|
||||
<ClInclude Include="..\..\beast\utility\hash_pair.h" />
|
||||
<ClInclude Include="..\..\beast\utility\Journal.h" />
|
||||
<ClInclude Include="..\..\beast\utility\LeakChecked.h" />
|
||||
<ClInclude Include="..\..\beast\utility\PropertyStream.h" />
|
||||
|
||||
@@ -1239,6 +1239,9 @@
|
||||
<ClInclude Include="..\..\beast\chrono\chrono_io.h">
|
||||
<Filter>beast\chrono</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\beast\utility\hash_pair.h">
|
||||
<Filter>beast\utility</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\modules\beast_core\containers\DynamicObject.cpp">
|
||||
|
||||
@@ -29,5 +29,7 @@
|
||||
#include "utility/PropertyStream.h"
|
||||
#include "utility/StaticObject.h"
|
||||
|
||||
#include "utility/hash_pair.h"
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -27,14 +27,6 @@
|
||||
|
||||
namespace beast {
|
||||
|
||||
template <class CharT, class Traits, class Duration1, class Duration2>
|
||||
std::basic_ostream <CharT, Traits>& operator<< (
|
||||
std::basic_ostream<CharT, Traits>& os, std::chrono::time_point <
|
||||
abstract_clock <Duration1>, Duration2> const& tp)
|
||||
{
|
||||
return os;
|
||||
}
|
||||
|
||||
class abstract_clock_tests : public UnitTest
|
||||
{
|
||||
public:
|
||||
|
||||
70
src/beast/beast/utility/hash_pair.h
Normal file
70
src/beast/beast/utility/hash_pair.h
Normal file
@@ -0,0 +1,70 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
This file is part of Beast: https://github.com/vinniefalco/Beast
|
||||
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef BEAST_UTILITY_HASH_PAIR_H_INCLUDED
|
||||
#define BEAST_UTILITY_HASH_PAIR_H_INCLUDED
|
||||
|
||||
#include <functional>
|
||||
#include <utility>
|
||||
|
||||
#include <boost/functional/hash.hpp>
|
||||
#include <boost/utility/base_from_member.hpp>
|
||||
|
||||
namespace std {
|
||||
|
||||
/** Specialization of std::hash for any std::pair type. */
|
||||
template <class First, class Second>
|
||||
struct hash <std::pair <First, Second>>
|
||||
: private boost::base_from_member <std::hash <First>, 0>
|
||||
, private boost::base_from_member <std::hash <Second>, 1>
|
||||
{
|
||||
private:
|
||||
typedef boost::base_from_member <std::hash <First>, 0> first_hash;
|
||||
typedef boost::base_from_member <std::hash <Second>, 1> second_hash;
|
||||
|
||||
public:
|
||||
hash ()
|
||||
{
|
||||
}
|
||||
|
||||
hash (std::hash <First> const& first_hash_,
|
||||
std::hash <Second> const& second_hash_)
|
||||
: first_hash (first_hash_)
|
||||
, second_hash (second_hash_)
|
||||
{
|
||||
}
|
||||
|
||||
std::size_t operator() (std::pair <First, Second> const& value)
|
||||
{
|
||||
std::size_t result (first_hash::member (value.first));
|
||||
boost::hash_combine (result, second_hash::member (value.second));
|
||||
return result;
|
||||
}
|
||||
|
||||
std::size_t operator() (std::pair <First, Second> const& value) const
|
||||
{
|
||||
std::size_t result (first_hash::member (value.first));
|
||||
boost::hash_combine (result, second_hash::member (value.second));
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user