Sprout/sprout/functional/hash/to_hash.hpp

44 lines
1.4 KiB
C++
Raw Normal View History

2013-08-08 09:54:33 +00:00
/*=============================================================================
2016-02-25 09:48:28 +00:00
Copyright (c) 2011-2016 Bolero MURAKAMI
2013-08-08 09:54:33 +00:00
https://github.com/bolero-MURAKAMI/Sprout
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
2013-02-04 09:42:39 +00:00
#ifndef SPROUT_FUNCTIONAL_HASH_TO_HASH_HPP
#define SPROUT_FUNCTIONAL_HASH_TO_HASH_HPP
#include <sprout/config.hpp>
#include <sprout/workaround/std/cstddef.hpp>
2013-02-04 09:42:39 +00:00
#include <sprout/functional/hash/hash_fwd.hpp>
#include <sprout/utility/forward.hpp>
#include <sprout/adl/not_found.hpp>
namespace sprout_adl {
sprout::not_found_via_adl hash_value(...);
} // namespace sprout_adl
namespace sprout {
//
// to_hash
//
2013-04-22 14:55:30 +00:00
// effect:
// ADL callable hash_value(v) -> hash_value(v)
// otherwise -> sprout::hash_value_traits<T>::hash_value(v)
// [default]
// v is Arithmetic || Enum || Pointer || Array -> implementation-defined
// otherwise -> std::hash<T>()(v)
//
2013-02-04 09:42:39 +00:00
template<typename T>
inline SPROUT_CONSTEXPR std::size_t
to_hash(T&& v) {
using sprout::hash_value;
using sprout_adl::hash_value;
return hash_value(SPROUT_FORWARD(T, v));
2013-02-04 09:42:39 +00:00
}
} // namespace sprout
#include <sprout/functional/hash/hash_value.hpp>
2013-02-04 09:42:39 +00:00
#endif // #ifndef SPROUT_FUNCTIONAL_HASH_TO_HASH_HPP