mirror of
https://github.com/bolero-MURAKAMI/Sprout
synced 2025-02-04 21:33:56 +00:00
change hash adapt
This commit is contained in:
parent
a7532930e3
commit
36e0b187c0
17 changed files with 505 additions and 220 deletions
17
sprout/adapt/boost/array.hpp
Normal file
17
sprout/adapt/boost/array.hpp
Normal file
|
@ -0,0 +1,17 @@
|
|||
/*=============================================================================
|
||||
Copyright (c) 2011-2016 Bolero MURAKAMI
|
||||
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)
|
||||
=============================================================================*/
|
||||
#ifndef SPROUT_ADAPT_BOOST_ARRAY_HPP
|
||||
#define SPROUT_ADAPT_BOOST_ARRAY_HPP
|
||||
|
||||
#include <array>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/container/boost/array.hpp>
|
||||
#include <sprout/functional/hash/boost/array.hpp>
|
||||
#include <sprout/tuple/boost/array.hpp>
|
||||
|
||||
#endif // #ifndef SPROUT_ADAPT_BOOST_ARRAY_HPP
|
63
sprout/container/boost/array.hpp
Normal file
63
sprout/container/boost/array.hpp
Normal file
|
@ -0,0 +1,63 @@
|
|||
/*=============================================================================
|
||||
Copyright (c) 2011-2016 Bolero MURAKAMI
|
||||
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)
|
||||
=============================================================================*/
|
||||
#ifndef SPROUT_CONTAINER_BOOST_ARRAY_HPP
|
||||
#define SPROUT_CONTAINER_BOOST_ARRAY_HPP
|
||||
|
||||
#include <boost/array.hpp>
|
||||
#include <sprout/config.hpp>
|
||||
#if SPROUT_USE_INDEX_ITERATOR_IMPLEMENTATION
|
||||
# include <type_traits>
|
||||
# include <sprout/workaround/std/cstddef.hpp>
|
||||
# include <sprout/container/traits.hpp>
|
||||
# include <sprout/iterator/index_iterator.hpp>
|
||||
#endif
|
||||
|
||||
#if SPROUT_USE_INDEX_ITERATOR_IMPLEMENTATION
|
||||
namespace sprout {
|
||||
//
|
||||
// container_traits
|
||||
//
|
||||
template<typename T, std::size_t N>
|
||||
struct container_traits<boost::array<T, N> >
|
||||
: public sprout::detail::container_traits_default<boost::array<T, N> >
|
||||
{
|
||||
public:
|
||||
typedef sprout::index_iterator<boost::array<T, N>&, true> iterator;
|
||||
typedef sprout::index_iterator<boost::array<T, N> const&, true> const_iterator;
|
||||
};
|
||||
|
||||
//
|
||||
// container_range_traits
|
||||
//
|
||||
template<typename T, std::size_t N>
|
||||
struct container_range_traits<boost::array<T, N> >
|
||||
: public sprout::detail::container_range_traits_default<boost::array<T, N> >
|
||||
{
|
||||
public:
|
||||
static SPROUT_CONSTEXPR typename sprout::container_traits<boost::array<T, N> >::iterator
|
||||
range_begin(boost::array<T, N>& cont) {
|
||||
return typename sprout::container_traits<boost::array<T, N> >::iterator(cont, 0);
|
||||
}
|
||||
static SPROUT_CONSTEXPR typename sprout::container_traits<boost::array<T, N> const>::iterator
|
||||
range_begin(boost::array<T, N> const& cont) {
|
||||
return typename sprout::container_traits<boost::array<T, N> const>::iterator(cont, 0);
|
||||
}
|
||||
|
||||
static SPROUT_CONSTEXPR typename sprout::container_traits<boost::array<T, N> >::iterator
|
||||
range_end(boost::array<T, N>& cont) {
|
||||
return typename sprout::container_traits<boost::array<T, N> >::iterator(cont, cont.size());
|
||||
}
|
||||
static SPROUT_CONSTEXPR typename sprout::container_traits<boost::array<T, N> const>::iterator
|
||||
range_end(boost::array<T, N> const& cont) {
|
||||
return typename sprout::container_traits<boost::array<T, N> const>::iterator(cont, cont.size());
|
||||
}
|
||||
};
|
||||
} // namespace sprout
|
||||
#endif
|
||||
|
||||
#endif // #ifndef SPROUT_CONTAINER_BOOST_ARRAY_HPP
|
31
sprout/functional/hash/boost/array.hpp
Normal file
31
sprout/functional/hash/boost/array.hpp
Normal file
|
@ -0,0 +1,31 @@
|
|||
/*=============================================================================
|
||||
Copyright (c) 2011-2016 Bolero MURAKAMI
|
||||
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)
|
||||
=============================================================================*/
|
||||
#ifndef SPROUT_FUNCTIONAL_HASH_BOOST_ARRAY_HPP
|
||||
#define SPROUT_FUNCTIONAL_HASH_BOOST_ARRAY_HPP
|
||||
|
||||
#include <boost/array.hpp>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/workaround/std/cstddef.hpp>
|
||||
#include <sprout/functional/hash/hash_value_traits.hpp>
|
||||
#include <sprout/functional/hash/hash_range.hpp>
|
||||
|
||||
namespace sprout {
|
||||
//
|
||||
// hash_value_traits
|
||||
//
|
||||
template<typename T, std::size_t N>
|
||||
struct hash_value_traits<boost::array<T, N> > {
|
||||
public:
|
||||
static SPROUT_CONSTEXPR std::size_t
|
||||
hash_value(boost::array<T, N> const& v) {
|
||||
return sprout::hash_range(v);
|
||||
}
|
||||
};
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_FUNCTIONAL_HASH_BOOST_ARRAY_HPP
|
|
@ -8,18 +8,163 @@
|
|||
#ifndef SPROUT_FUNCTIONAL_HASH_HASH_VALUE_HPP
|
||||
#define SPROUT_FUNCTIONAL_HASH_HASH_VALUE_HPP
|
||||
|
||||
#include <functional>
|
||||
#include <type_traits>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/workaround/std/cstddef.hpp>
|
||||
#include <sprout/limits.hpp>
|
||||
#include <sprout/functional/hash/hash_fwd.hpp>
|
||||
#include <sprout/functional/hash/detail/hash_float.hpp>
|
||||
#include <sprout/type_traits/integral_constant.hpp>
|
||||
#include <sprout/type_traits/is_signed.hpp>
|
||||
#include <sprout/type_traits/is_unsigned.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace hash_detail {
|
||||
template<typename T>
|
||||
struct is_basic_number
|
||||
: public sprout::bool_constant<
|
||||
std::is_integral<T>::value
|
||||
&& (sizeof(T) <= sizeof(std::size_t))
|
||||
>
|
||||
{};
|
||||
template<typename T>
|
||||
struct is_long_number
|
||||
: public sprout::bool_constant<
|
||||
std::is_integral<T>::value
|
||||
&& (sizeof(T) > sizeof(std::size_t))
|
||||
&& sprout::is_signed<T>::value
|
||||
>
|
||||
{};
|
||||
template<typename T>
|
||||
struct is_ulong_number
|
||||
: public sprout::bool_constant<
|
||||
std::is_integral<T>::value
|
||||
&& (sizeof(T) > sizeof(std::size_t))
|
||||
&& sprout::is_unsigned<T>::value
|
||||
>
|
||||
{};
|
||||
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR std::size_t
|
||||
hash_value_signed_2(T val, int length, std::size_t seed, T positive, std::size_t i) {
|
||||
return i > 0
|
||||
? hash_value_signed_2(
|
||||
val,
|
||||
length,
|
||||
seed ^ static_cast<std::size_t>((positive >> i) + (seed << 6) + (seed >> 2)),
|
||||
positive,
|
||||
i - sprout::numeric_limits<std::size_t>::digits
|
||||
)
|
||||
: seed ^ static_cast<std::size_t>(val + (seed << 6) + (seed >> 2))
|
||||
;
|
||||
}
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR std::size_t
|
||||
hash_value_signed_1(T val, int length, std::size_t seed, T positive) {
|
||||
return hash_value_signed_2(val, length, seed, positive, length * sprout::numeric_limits<std::size_t>::digits);
|
||||
}
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR std::size_t
|
||||
hash_value_signed(T val) {
|
||||
return sprout::hash_detail::hash_value_signed_1(
|
||||
val,
|
||||
(sprout::numeric_limits<T>::digits - 1) / sprout::numeric_limits<std::size_t>::digits,
|
||||
0,
|
||||
val < 0 ? -1 - val : val
|
||||
);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR std::size_t
|
||||
hash_value_unsigned_2(T val, int length, std::size_t seed, std::size_t i) {
|
||||
return i > 0
|
||||
? hash_value_unsigned_2(
|
||||
val,
|
||||
length,
|
||||
seed ^ static_cast<std::size_t>((val >> i) + (seed << 6) + (seed >> 2)),
|
||||
i - sprout::numeric_limits<std::size_t>::digits
|
||||
)
|
||||
: seed ^ static_cast<std::size_t>(val + (seed << 6) + (seed >> 2))
|
||||
;
|
||||
}
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR std::size_t
|
||||
hash_value_unsigned_1(T val, int length, std::size_t seed) {
|
||||
return hash_value_unsigned_2(val, length, seed, length * sprout::numeric_limits<std::size_t>::digits);
|
||||
}
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR std::size_t
|
||||
hash_value_unsigned(T val) {
|
||||
return sprout::hash_detail::hash_value_unsigned_1(
|
||||
val,
|
||||
(sprout::numeric_limits<T>::digits - 1) / sprout::numeric_limits<std::size_t>::digits,
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
inline std::size_t
|
||||
hash_value_pointer_1(std::size_t x) {
|
||||
return x + (x >> 3);
|
||||
}
|
||||
template<typename T>
|
||||
std::size_t
|
||||
hash_value_pointer(T const* v) {
|
||||
return sprout::hash_detail::hash_value_pointer_1(static_cast<std::size_t>(reinterpret_cast<std::ptrdiff_t>(v)));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<sprout::hash_detail::is_basic_number<T>::value, std::size_t>::type
|
||||
hash_value_impl(T v) {
|
||||
return static_cast<std::size_t>(v);
|
||||
}
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<sprout::hash_detail::is_long_number<T>::value, std::size_t>::type
|
||||
hash_value_impl(T v) {
|
||||
return sprout::hash_detail::hash_value_signed(v);
|
||||
}
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<sprout::hash_detail::is_ulong_number<T>::value, std::size_t>::type
|
||||
hash_value_impl(T v) {
|
||||
return sprout::hash_detail::hash_value_unsigned(v);
|
||||
}
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<std::is_enum<T>::value, std::size_t>::type
|
||||
hash_value_impl(T v) {
|
||||
return sprout::hash_detail::hash_value_impl(static_cast<typename std::underlying_type<T>::type>(v));
|
||||
}
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<std::is_floating_point<T>::value, std::size_t>::type
|
||||
hash_value_impl(T v) {
|
||||
return sprout::detail::float_hash_value(v);
|
||||
}
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<std::is_pointer<typename std::remove_reference<T>::type>::value, std::size_t>::type
|
||||
hash_value_impl(T&& v) {
|
||||
return sprout::hash_detail::hash_value_pointer(v);
|
||||
}
|
||||
template<typename T, std::size_t N>
|
||||
inline SPROUT_CONSTEXPR std::size_t
|
||||
hash_value_impl(T const (& v)[N]) {
|
||||
return sprout::hash_range(v);
|
||||
}
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||
!std::is_arithmetic<T>::value && !std::is_enum<T>::value && !std::is_pointer<T>::value,
|
||||
std::size_t
|
||||
>::type
|
||||
hash_value_impl(T const& v) {
|
||||
return std::hash<typename std::decay<T>::type>()(v);
|
||||
}
|
||||
} // namespace hash_detail
|
||||
|
||||
//
|
||||
// hash_value
|
||||
//
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR std::size_t
|
||||
hash_value(T const& v) {
|
||||
return sprout::hash_value_traits<T>::hash_value(v);
|
||||
return sprout::hash_detail::hash_value_impl(v);
|
||||
}
|
||||
} // namespace sprout
|
||||
|
||||
|
|
|
@ -8,156 +8,26 @@
|
|||
#ifndef SPROUT_FUNCTIONAL_HASH_HASH_VALUE_TRAITS_HPP
|
||||
#define SPROUT_FUNCTIONAL_HASH_HASH_VALUE_TRAITS_HPP
|
||||
|
||||
#include <functional>
|
||||
#include <type_traits>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/workaround/std/cstddef.hpp>
|
||||
#include <sprout/limits.hpp>
|
||||
#include <sprout/functional/hash/hash_fwd.hpp>
|
||||
#include <sprout/functional/hash/detail/hash_float.hpp>
|
||||
#include <sprout/type_traits/integral_constant.hpp>
|
||||
#include <sprout/type_traits/is_signed.hpp>
|
||||
#include <sprout/type_traits/is_unsigned.hpp>
|
||||
#include <sprout/adl/not_found.hpp>
|
||||
|
||||
namespace sprout_adl {
|
||||
sprout::not_found_via_adl hash_value(...);
|
||||
} // namespace sprout_adl
|
||||
|
||||
namespace sprout_hash_detail {
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR std::size_t
|
||||
call_hash_value(T const& v) {
|
||||
using sprout::hash_value;
|
||||
using sprout_adl::hash_value;
|
||||
return hash_value(v);
|
||||
}
|
||||
} // namespace sprout_hash_detail
|
||||
|
||||
namespace sprout {
|
||||
namespace hash_detail {
|
||||
template<typename T>
|
||||
struct is_basic_number
|
||||
: public sprout::bool_constant<
|
||||
std::is_integral<T>::value
|
||||
&& (sizeof(T) <= sizeof(std::size_t))
|
||||
>
|
||||
{};
|
||||
template<typename T>
|
||||
struct is_long_number
|
||||
: public sprout::bool_constant<
|
||||
std::is_integral<T>::value
|
||||
&& (sizeof(T) > sizeof(std::size_t))
|
||||
&& sprout::is_signed<T>::value
|
||||
>
|
||||
{};
|
||||
template<typename T>
|
||||
struct is_ulong_number
|
||||
: public sprout::bool_constant<
|
||||
std::is_integral<T>::value
|
||||
&& (sizeof(T) > sizeof(std::size_t))
|
||||
&& sprout::is_unsigned<T>::value
|
||||
>
|
||||
{};
|
||||
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR std::size_t
|
||||
hash_value_signed_2(T val, int length, std::size_t seed, T positive, std::size_t i) {
|
||||
return i > 0
|
||||
? hash_value_signed_2(
|
||||
val,
|
||||
length,
|
||||
seed ^ static_cast<std::size_t>((positive >> i) + (seed << 6) + (seed >> 2)),
|
||||
positive,
|
||||
i - sprout::numeric_limits<std::size_t>::digits
|
||||
)
|
||||
: seed ^ static_cast<std::size_t>(val + (seed << 6) + (seed >> 2))
|
||||
;
|
||||
}
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR std::size_t
|
||||
hash_value_signed_1(T val, int length, std::size_t seed, T positive) {
|
||||
return hash_value_signed_2(val, length, seed, positive, length * sprout::numeric_limits<std::size_t>::digits);
|
||||
}
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR std::size_t
|
||||
hash_value_signed(T val) {
|
||||
return sprout::hash_detail::hash_value_signed_1(
|
||||
val,
|
||||
(sprout::numeric_limits<T>::digits - 1) / sprout::numeric_limits<std::size_t>::digits,
|
||||
0,
|
||||
val < 0 ? -1 - val : val
|
||||
);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR std::size_t
|
||||
hash_value_unsigned_2(T val, int length, std::size_t seed, std::size_t i) {
|
||||
return i > 0
|
||||
? hash_value_unsigned_2(
|
||||
val,
|
||||
length,
|
||||
seed ^ static_cast<std::size_t>((val >> i) + (seed << 6) + (seed >> 2)),
|
||||
i - sprout::numeric_limits<std::size_t>::digits
|
||||
)
|
||||
: seed ^ static_cast<std::size_t>(val + (seed << 6) + (seed >> 2))
|
||||
;
|
||||
}
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR std::size_t
|
||||
hash_value_unsigned_1(T val, int length, std::size_t seed) {
|
||||
return hash_value_unsigned_2(val, length, seed, length * sprout::numeric_limits<std::size_t>::digits);
|
||||
}
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR std::size_t
|
||||
hash_value_unsigned(T val) {
|
||||
return sprout::hash_detail::hash_value_unsigned_1(
|
||||
val,
|
||||
(sprout::numeric_limits<T>::digits - 1) / sprout::numeric_limits<std::size_t>::digits,
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
inline std::size_t
|
||||
hash_value_pointer_1(std::size_t x) {
|
||||
return x + (x >> 3);
|
||||
}
|
||||
template<typename T>
|
||||
std::size_t
|
||||
hash_value_pointer(T const* v) {
|
||||
return sprout::hash_detail::hash_value_pointer_1(static_cast<std::size_t>(reinterpret_cast<std::ptrdiff_t>(v)));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<sprout::hash_detail::is_basic_number<T>::value, std::size_t>::type
|
||||
hash_value_impl(T v) {
|
||||
return static_cast<std::size_t>(v);
|
||||
}
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<sprout::hash_detail::is_long_number<T>::value, std::size_t>::type
|
||||
hash_value_impl(T v) {
|
||||
return sprout::hash_detail::hash_value_signed(v);
|
||||
}
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<sprout::hash_detail::is_ulong_number<T>::value, std::size_t>::type
|
||||
hash_value_impl(T v) {
|
||||
return sprout::hash_detail::hash_value_unsigned(v);
|
||||
}
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<std::is_enum<T>::value, std::size_t>::type
|
||||
hash_value_impl(T v) {
|
||||
return sprout::hash_detail::hash_value_impl(static_cast<typename std::underlying_type<T>::type>(v));
|
||||
}
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<std::is_floating_point<T>::value, std::size_t>::type
|
||||
hash_value_impl(T v) {
|
||||
return sprout::detail::float_hash_value(v);
|
||||
}
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<std::is_pointer<typename std::remove_reference<T>::type>::value, std::size_t>::type
|
||||
hash_value_impl(T&& v) {
|
||||
return sprout::hash_detail::hash_value_pointer(v);
|
||||
}
|
||||
template<typename T, std::size_t N>
|
||||
inline SPROUT_CONSTEXPR std::size_t
|
||||
hash_value_impl(T const (& v)[N]) {
|
||||
return sprout::hash_range(v);
|
||||
}
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||
!std::is_arithmetic<T>::value && !std::is_enum<T>::value && !std::is_pointer<T>::value,
|
||||
std::size_t
|
||||
>::type
|
||||
hash_value_impl(T const& v) {
|
||||
return std::hash<typename std::decay<T>::type>()(v);
|
||||
}
|
||||
} // namespace hash_detail
|
||||
|
||||
//
|
||||
// hash_value_traits
|
||||
//
|
||||
|
@ -166,7 +36,7 @@ namespace sprout {
|
|||
public:
|
||||
static SPROUT_CONSTEXPR std::size_t
|
||||
hash_value(T const& v) {
|
||||
return sprout::hash_detail::hash_value_impl(v);
|
||||
return sprout_hash_detail::call_hash_value(v);
|
||||
}
|
||||
};
|
||||
template<typename T>
|
||||
|
@ -184,5 +54,6 @@ namespace sprout {
|
|||
} // namespace sprout
|
||||
|
||||
#include <sprout/functional/hash/hash_range.hpp>
|
||||
#include <sprout/functional/hash/hash_value.hpp>
|
||||
|
||||
#endif // #ifndef SPROUT_FUNCTIONAL_HASH_HASH_VALUE_TRAITS_HPP
|
||||
|
|
|
@ -11,33 +11,26 @@
|
|||
#include <sprout/config.hpp>
|
||||
#include <sprout/workaround/std/cstddef.hpp>
|
||||
#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
|
||||
//
|
||||
// effect:
|
||||
// ADL callable hash_value(v) -> hash_value(v)
|
||||
// otherwise -> sprout::hash_value_traits<T>::hash_value(v)
|
||||
// sprout::hash_value_traits<T>::hash_value(v)
|
||||
// [default]
|
||||
// v is Arithmetic || Enum || Pointer || Array -> implementation-defined
|
||||
// otherwise -> std::hash<T>()(v)
|
||||
// ADL callable hash_value(v) -> hash_value(v)
|
||||
// [default]
|
||||
// T is Arithmetic || Enum || Pointer || Array -> implementation-defined
|
||||
// otherwise -> std::hash<T>()(v)
|
||||
//
|
||||
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));
|
||||
return sprout::hash_value_traits<T>::hash_value(v);
|
||||
}
|
||||
} // namespace sprout
|
||||
|
||||
#include <sprout/functional/hash/hash_value.hpp>
|
||||
#include <sprout/functional/hash/hash_value_traits.hpp>
|
||||
|
||||
#endif // #ifndef SPROUT_FUNCTIONAL_HASH_TO_HASH_HPP
|
||||
|
|
48
sprout/tuple/boost/array.hpp
Normal file
48
sprout/tuple/boost/array.hpp
Normal file
|
@ -0,0 +1,48 @@
|
|||
/*=============================================================================
|
||||
Copyright (c) 2011-2016 Bolero MURAKAMI
|
||||
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)
|
||||
=============================================================================*/
|
||||
#ifndef SPROUT_TUPLE_BOOST_ARRAY_HPP
|
||||
#define SPROUT_TUPLE_BOOST_ARRAY_HPP
|
||||
|
||||
#include <type_traits>
|
||||
#include <array>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/workaround/std/cstddef.hpp>
|
||||
#include <sprout/utility/move.hpp>
|
||||
#include <sprout/tuple/tuple/tuple_access_traits.hpp>
|
||||
#include <sprout/tuple/tuple/get.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace tuples {
|
||||
//
|
||||
// tuple_access_traits
|
||||
//
|
||||
template<typename T, std::size_t N>
|
||||
struct tuple_access_traits<boost::array<T, N> > {
|
||||
public:
|
||||
template<std::size_t I>
|
||||
static SPROUT_CONSTEXPR T&
|
||||
tuple_get(boost::array<T, N>& t) SPROUT_NOEXCEPT {
|
||||
static_assert(I < N, "tuple_get: index out of range");
|
||||
return t[I];
|
||||
}
|
||||
template<std::size_t I>
|
||||
static SPROUT_CONSTEXPR T const&
|
||||
tuple_get(boost::array<T, N> const& t) SPROUT_NOEXCEPT {
|
||||
static_assert(I < N, "tuple_get: index out of range");
|
||||
return t[I];
|
||||
}
|
||||
template<std::size_t I>
|
||||
static SPROUT_CONSTEXPR T&&
|
||||
tuple_get(boost::array<T, N>&& t) SPROUT_NOEXCEPT {
|
||||
return sprout::move(tuple_get<I>(t));
|
||||
}
|
||||
};
|
||||
} // namespace tuples
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_TUPLE_BOOST_ARRAY_HPP
|
22
sprout/type_traits/has_arithmetic_operator.hpp
Normal file
22
sprout/type_traits/has_arithmetic_operator.hpp
Normal file
|
@ -0,0 +1,22 @@
|
|||
/*=============================================================================
|
||||
Copyright (c) 2011-2016 Bolero MURAKAMI
|
||||
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)
|
||||
=============================================================================*/
|
||||
#ifndef SPROUT_TYPE_TRAITS_HAS_ARITHMETIC_OPERATOR_HPP
|
||||
#define SPROUT_TYPE_TRAITS_HAS_ARITHMETIC_OPERATOR_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/type_traits/has_plus.hpp>
|
||||
#include <sprout/type_traits/has_minus.hpp>
|
||||
#include <sprout/type_traits/has_multiplies.hpp>
|
||||
#include <sprout/type_traits/has_divides.hpp>
|
||||
#include <sprout/type_traits/has_modulus.hpp>
|
||||
#include <sprout/type_traits/has_negate.hpp>
|
||||
#include <sprout/type_traits/has_posite.hpp>
|
||||
#include <sprout/type_traits/has_unary_minus.hpp>
|
||||
#include <sprout/type_traits/has_unary_plus.hpp>
|
||||
|
||||
#endif // #ifndef SPROUT_TYPE_TRAITS_HAS_ARITHMETIC_OPERATOR_HPP
|
26
sprout/type_traits/has_assignment_operator.hpp
Normal file
26
sprout/type_traits/has_assignment_operator.hpp
Normal file
|
@ -0,0 +1,26 @@
|
|||
/*=============================================================================
|
||||
Copyright (c) 2011-2016 Bolero MURAKAMI
|
||||
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)
|
||||
=============================================================================*/
|
||||
#ifndef SPROUT_TYPE_TRAITS_HAS_ASSIGNMENT_OPERATOR_HPP
|
||||
#define SPROUT_TYPE_TRAITS_HAS_ASSIGNMENT_OPERATOR_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/type_traits/has_assign.hpp>
|
||||
#include <sprout/type_traits/has_plus_assign.hpp>
|
||||
#include <sprout/type_traits/has_minus_assign.hpp>
|
||||
#include <sprout/type_traits/has_multiplies_assign.hpp>
|
||||
#include <sprout/type_traits/has_divides_assign.hpp>
|
||||
#include <sprout/type_traits/has_modulus_assign.hpp>
|
||||
#include <sprout/type_traits/has_bit_and_assign.hpp>
|
||||
#include <sprout/type_traits/has_bit_or_assign.hpp>
|
||||
#include <sprout/type_traits/has_bit_xor_assign.hpp>
|
||||
#include <sprout/type_traits/has_shift_left_assign.hpp>
|
||||
#include <sprout/type_traits/has_shift_right_assign.hpp>
|
||||
#include <sprout/type_traits/has_left_shift_assign.hpp>
|
||||
#include <sprout/type_traits/has_right_shift_assign.hpp>
|
||||
|
||||
#endif // #ifndef SPROUT_TYPE_TRAITS_HAS_ASSIGNMENT_OPERATOR_HPP
|
22
sprout/type_traits/has_bitwise_operator.hpp
Normal file
22
sprout/type_traits/has_bitwise_operator.hpp
Normal file
|
@ -0,0 +1,22 @@
|
|||
/*=============================================================================
|
||||
Copyright (c) 2011-2016 Bolero MURAKAMI
|
||||
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)
|
||||
=============================================================================*/
|
||||
#ifndef SPROUT_TYPE_TRAITS_HAS_BITWAISE_OPERATOR_HPP
|
||||
#define SPROUT_TYPE_TRAITS_HAS_BITWAISE_OPERATOR_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/type_traits/has_bit_and.hpp>
|
||||
#include <sprout/type_traits/has_bit_or.hpp>
|
||||
#include <sprout/type_traits/has_bit_xor.hpp>
|
||||
#include <sprout/type_traits/has_bit_not.hpp>
|
||||
#include <sprout/type_traits/has_shift_left.hpp>
|
||||
#include <sprout/type_traits/has_shift_right.hpp>
|
||||
#include <sprout/type_traits/has_complement.hpp>
|
||||
#include <sprout/type_traits/has_left_shift.hpp>
|
||||
#include <sprout/type_traits/has_right_shift.hpp>
|
||||
|
||||
#endif // #ifndef SPROUT_TYPE_TRAITS_HAS_BITWAISE_OPERATOR_HPP
|
19
sprout/type_traits/has_comparison_operator.hpp
Normal file
19
sprout/type_traits/has_comparison_operator.hpp
Normal file
|
@ -0,0 +1,19 @@
|
|||
/*=============================================================================
|
||||
Copyright (c) 2011-2016 Bolero MURAKAMI
|
||||
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)
|
||||
=============================================================================*/
|
||||
#ifndef SPROUT_TYPE_TRAITS_HAS_COMPARISON_OPERATOR_HPP
|
||||
#define SPROUT_TYPE_TRAITS_HAS_COMPARISON_OPERATOR_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/type_traits/has_equal_to.hpp>
|
||||
#include <sprout/type_traits/has_not_equal_to.hpp>
|
||||
#include <sprout/type_traits/has_greater.hpp>
|
||||
#include <sprout/type_traits/has_less.hpp>
|
||||
#include <sprout/type_traits/has_greater_equal.hpp>
|
||||
#include <sprout/type_traits/has_less_equal.hpp>
|
||||
|
||||
#endif // #ifndef SPROUT_TYPE_TRAITS_HAS_COMPARISON_OPERATOR_HPP
|
17
sprout/type_traits/has_inc_dec_operator.hpp
Normal file
17
sprout/type_traits/has_inc_dec_operator.hpp
Normal file
|
@ -0,0 +1,17 @@
|
|||
/*=============================================================================
|
||||
Copyright (c) 2011-2016 Bolero MURAKAMI
|
||||
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)
|
||||
=============================================================================*/
|
||||
#ifndef SPROUT_TYPE_TRAITS_HAS_INC_DEC_OPERATOR_HPP
|
||||
#define SPROUT_TYPE_TRAITS_HAS_INC_DEC_OPERATOR_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/type_traits/has_pre_increment.hpp>
|
||||
#include <sprout/type_traits/has_pre_decrement.hpp>
|
||||
#include <sprout/type_traits/has_post_increment.hpp>
|
||||
#include <sprout/type_traits/has_post_decrement.hpp>
|
||||
|
||||
#endif // #ifndef SPROUT_TYPE_TRAITS_HAS_INC_DEC_OPERATOR_HPP
|
16
sprout/type_traits/has_logical_operator.hpp
Normal file
16
sprout/type_traits/has_logical_operator.hpp
Normal file
|
@ -0,0 +1,16 @@
|
|||
/*=============================================================================
|
||||
Copyright (c) 2011-2016 Bolero MURAKAMI
|
||||
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)
|
||||
=============================================================================*/
|
||||
#ifndef SPROUT_TYPE_TRAITS_HAS_LOGICAL_OPERATOR_HPP
|
||||
#define SPROUT_TYPE_TRAITS_HAS_LOGICAL_OPERATOR_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/type_traits/has_logical_and.hpp>
|
||||
#include <sprout/type_traits/has_logical_or.hpp>
|
||||
#include <sprout/type_traits/has_logical_not.hpp>
|
||||
|
||||
#endif // #ifndef SPROUT_TYPE_TRAITS_HAS_LOGICAL_OPERATOR_HPP
|
15
sprout/type_traits/has_members_operator.hpp
Normal file
15
sprout/type_traits/has_members_operator.hpp
Normal file
|
@ -0,0 +1,15 @@
|
|||
/*=============================================================================
|
||||
Copyright (c) 2011-2016 Bolero MURAKAMI
|
||||
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)
|
||||
=============================================================================*/
|
||||
#ifndef SPROUT_TYPE_TRAITS_HAS_MEMBERS_OPERATOR_HPP
|
||||
#define SPROUT_TYPE_TRAITS_HAS_MEMBERS_OPERATOR_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/type_traits/has_member_pointer.hpp>
|
||||
#include <sprout/type_traits/has_member.hpp>
|
||||
|
||||
#endif // #ifndef SPROUT_TYPE_TRAITS_HAS_MEMBERS_OPERATOR_HPP
|
|
@ -9,64 +9,14 @@
|
|||
#define SPROUT_TYPE_TRAITS_HAS_OPERATOR_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
// arithmetic
|
||||
#include <sprout/type_traits/has_plus.hpp>
|
||||
#include <sprout/type_traits/has_minus.hpp>
|
||||
#include <sprout/type_traits/has_multiplies.hpp>
|
||||
#include <sprout/type_traits/has_divides.hpp>
|
||||
#include <sprout/type_traits/has_modulus.hpp>
|
||||
#include <sprout/type_traits/has_negate.hpp>
|
||||
#include <sprout/type_traits/has_posite.hpp>
|
||||
#include <sprout/type_traits/has_unary_minus.hpp>
|
||||
#include <sprout/type_traits/has_unary_plus.hpp>
|
||||
// comparison
|
||||
#include <sprout/type_traits/has_equal_to.hpp>
|
||||
#include <sprout/type_traits/has_not_equal_to.hpp>
|
||||
#include <sprout/type_traits/has_greater.hpp>
|
||||
#include <sprout/type_traits/has_less.hpp>
|
||||
#include <sprout/type_traits/has_greater_equal.hpp>
|
||||
#include <sprout/type_traits/has_less_equal.hpp>
|
||||
// logical
|
||||
#include <sprout/type_traits/has_logical_and.hpp>
|
||||
#include <sprout/type_traits/has_logical_or.hpp>
|
||||
#include <sprout/type_traits/has_logical_not.hpp>
|
||||
// bitwise
|
||||
#include <sprout/type_traits/has_bit_and.hpp>
|
||||
#include <sprout/type_traits/has_bit_or.hpp>
|
||||
#include <sprout/type_traits/has_bit_xor.hpp>
|
||||
#include <sprout/type_traits/has_bit_not.hpp>
|
||||
#include <sprout/type_traits/has_shift_left.hpp>
|
||||
#include <sprout/type_traits/has_shift_right.hpp>
|
||||
#include <sprout/type_traits/has_complement.hpp>
|
||||
#include <sprout/type_traits/has_left_shift.hpp>
|
||||
#include <sprout/type_traits/has_right_shift.hpp>
|
||||
// inc_dec
|
||||
#include <sprout/type_traits/has_pre_increment.hpp>
|
||||
#include <sprout/type_traits/has_pre_decrement.hpp>
|
||||
#include <sprout/type_traits/has_post_increment.hpp>
|
||||
#include <sprout/type_traits/has_post_decrement.hpp>
|
||||
// reference
|
||||
#include <sprout/type_traits/has_address_of.hpp>
|
||||
#include <sprout/type_traits/has_dereference.hpp>
|
||||
// assignment
|
||||
#include <sprout/type_traits/has_assign.hpp>
|
||||
#include <sprout/type_traits/has_plus_assign.hpp>
|
||||
#include <sprout/type_traits/has_minus_assign.hpp>
|
||||
#include <sprout/type_traits/has_multiplies_assign.hpp>
|
||||
#include <sprout/type_traits/has_divides_assign.hpp>
|
||||
#include <sprout/type_traits/has_modulus_assign.hpp>
|
||||
#include <sprout/type_traits/has_bit_and_assign.hpp>
|
||||
#include <sprout/type_traits/has_bit_or_assign.hpp>
|
||||
#include <sprout/type_traits/has_bit_xor_assign.hpp>
|
||||
#include <sprout/type_traits/has_shift_left_assign.hpp>
|
||||
#include <sprout/type_traits/has_shift_right_assign.hpp>
|
||||
#include <sprout/type_traits/has_left_shift_assign.hpp>
|
||||
#include <sprout/type_traits/has_right_shift_assign.hpp>
|
||||
// members
|
||||
#include <sprout/type_traits/has_member_pointer.hpp>
|
||||
#include <sprout/type_traits/has_member.hpp>
|
||||
// various
|
||||
#include <sprout/type_traits/has_subscript.hpp>
|
||||
#include <sprout/type_traits/has_comma.hpp>
|
||||
#include <sprout/type_traits/has_arithmetic_operator.hpp>
|
||||
#include <sprout/type_traits/has_comparison_operator.hpp>
|
||||
#include <sprout/type_traits/has_logical_operator.hpp>
|
||||
#include <sprout/type_traits/has_bitwise_operator.hpp>
|
||||
#include <sprout/type_traits/has_inc_dec_operator.hpp>
|
||||
#include <sprout/type_traits/has_reference_operator.hpp>
|
||||
#include <sprout/type_traits/has_assignment_operator.hpp>
|
||||
#include <sprout/type_traits/has_members_operator.hpp>
|
||||
#include <sprout/type_traits/has_various_operator.hpp>
|
||||
|
||||
#endif // #ifndef SPROUT_TYPE_TRAITS_HAS_OPERATOR_HPP
|
||||
|
|
15
sprout/type_traits/has_reference_operator.hpp
Normal file
15
sprout/type_traits/has_reference_operator.hpp
Normal file
|
@ -0,0 +1,15 @@
|
|||
/*=============================================================================
|
||||
Copyright (c) 2011-2016 Bolero MURAKAMI
|
||||
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)
|
||||
=============================================================================*/
|
||||
#ifndef SPROUT_TYPE_TRAITS_HAS_REFERENCE_OPERATOR_HPP
|
||||
#define SPROUT_TYPE_TRAITS_HAS_REFERENCE_OPERATOR_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/type_traits/has_address_of.hpp>
|
||||
#include <sprout/type_traits/has_dereference.hpp>
|
||||
|
||||
#endif // #ifndef SPROUT_TYPE_TRAITS_HAS_REFERENCE_OPERATOR_HPP
|
15
sprout/type_traits/has_various_operator.hpp
Normal file
15
sprout/type_traits/has_various_operator.hpp
Normal file
|
@ -0,0 +1,15 @@
|
|||
/*=============================================================================
|
||||
Copyright (c) 2011-2016 Bolero MURAKAMI
|
||||
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)
|
||||
=============================================================================*/
|
||||
#ifndef SPROUT_TYPE_TRAITS_HAS_VARIOUS_OPERATOR_HPP
|
||||
#define SPROUT_TYPE_TRAITS_HAS_VARIOUS_OPERATOR_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/type_traits/has_subscript.hpp>
|
||||
#include <sprout/type_traits/has_comma.hpp>
|
||||
|
||||
#endif // #ifndef SPROUT_TYPE_TRAITS_HAS_VARIOUS_OPERATOR_HPP
|
Loading…
Add table
Reference in a new issue