mirror of
https://github.com/bolero-MURAKAMI/Sprout
synced 2025-10-05 13:00:00 +00:00
rewrite hash implementation
This commit is contained in:
parent
87ee4f4032
commit
d00e971abe
13 changed files with 262 additions and 269 deletions
|
@ -12,7 +12,7 @@
|
|||
#include <sprout/tuple/tuple.hpp>
|
||||
#include <sprout/functional/ref.hpp>
|
||||
#include <sprout/functional/mem_fn.hpp>
|
||||
#include <sprout/functional/weak_result_type.hpp>
|
||||
#include <sprout/functional/type_traits/weak_result_type.hpp>
|
||||
|
||||
namespace sprout {
|
||||
// 20.8.9 bind
|
||||
|
|
|
@ -4,58 +4,71 @@
|
|||
#include <type_traits>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/functional/base.hpp>
|
||||
#include <sprout/functional/type_traits.hpp>
|
||||
#include <sprout/functional/type_traits/is_strict_function.hpp>
|
||||
|
||||
namespace sprout {
|
||||
// Copyright (C) 2011 RiSK (sscrisk)
|
||||
|
||||
// D.9.1 Class template binder1st
|
||||
template<typename Fn, typename T = void, typename = void>
|
||||
class binder1st;
|
||||
template<typename Fn, typename T>
|
||||
class binder1st<
|
||||
Fn, T,
|
||||
typename std::enable_if<sprout::is_strict_binary_function<Fn>::value>::type
|
||||
>
|
||||
: public sprout::unary_function<typename Fn::second_argument_type, typename Fn::result_type>
|
||||
namespace detail {
|
||||
template<typename Fn, typename T = void, typename = void>
|
||||
class binder1st;
|
||||
template<typename Fn, typename T>
|
||||
class binder1st<
|
||||
Fn, T,
|
||||
typename std::enable_if<sprout::is_strict_binary_function<Fn>::value>::type
|
||||
>
|
||||
: public sprout::unary_function<typename Fn::second_argument_type, typename Fn::result_type>
|
||||
{
|
||||
public:
|
||||
typedef typename std::conditional<
|
||||
std::is_void<T>::value,
|
||||
typename Fn::first_argument_type,
|
||||
T
|
||||
>::type value_type;
|
||||
protected:
|
||||
Fn op;
|
||||
value_type value;
|
||||
public:
|
||||
SPROUT_CONSTEXPR binder1st(Fn const& x, value_type const& y)
|
||||
: op(x), value(y)
|
||||
{}
|
||||
SPROUT_CONSTEXPR typename Fn::result_type
|
||||
operator()(typename Fn::second_argument_type const& x) const {
|
||||
return op(value, x);
|
||||
}
|
||||
};
|
||||
template<typename Fn, typename T>
|
||||
class binder1st<
|
||||
Fn, T,
|
||||
typename std::enable_if<!sprout::is_strict_binary_function<Fn>::value>::type
|
||||
> {
|
||||
public:
|
||||
typedef T value_type;
|
||||
protected:
|
||||
Fn op;
|
||||
value_type value;
|
||||
public:
|
||||
SPROUT_CONSTEXPR binder1st(Fn const& x, value_type const& y)
|
||||
: op(x), value(y)
|
||||
{}
|
||||
template<typename U>
|
||||
SPROUT_CONSTEXPR decltype(op(value, std::declval<U const&>()))
|
||||
operator()(U const& x) const {
|
||||
return op(value, x);
|
||||
}
|
||||
};
|
||||
} // namespace detail
|
||||
template<typename Fn, typename T = void>
|
||||
class binder1st
|
||||
: public sprout::detail::binder1st<Fn, T>
|
||||
{
|
||||
public:
|
||||
typedef typename std::conditional<
|
||||
std::is_void<T>::value,
|
||||
typename Fn::first_argument_type,
|
||||
T
|
||||
>::type value_type;
|
||||
protected:
|
||||
Fn op;
|
||||
value_type value;
|
||||
typedef typename sprout::detail::binder1st<Fn, T>::value_type value_type;
|
||||
public:
|
||||
SPROUT_CONSTEXPR binder1st(Fn const& x, value_type const& y)
|
||||
: op(x), value(y)
|
||||
: sprout::detail::binder1st<Fn, T>(x, y)
|
||||
{}
|
||||
SPROUT_CONSTEXPR typename Fn::result_type
|
||||
operator()(typename Fn::second_argument_type const& x) const {
|
||||
return op(value, x);
|
||||
}
|
||||
};
|
||||
template<typename Fn, typename T>
|
||||
class binder1st<
|
||||
Fn, T,
|
||||
typename std::enable_if<!sprout::is_strict_binary_function<Fn>::value>::type
|
||||
> {
|
||||
public:
|
||||
typedef T value_type;
|
||||
protected:
|
||||
Fn op;
|
||||
value_type value;
|
||||
public:
|
||||
SPROUT_CONSTEXPR binder1st(Fn const& x, value_type const& y)
|
||||
: op(x), value(y)
|
||||
{}
|
||||
template<typename U>
|
||||
SPROUT_CONSTEXPR decltype(op(value, std::declval<U const&>()))
|
||||
operator()(U const& x) const {
|
||||
return op(value, x);
|
||||
}
|
||||
};
|
||||
|
||||
// D.9.2 bind1st
|
||||
|
|
|
@ -1,59 +1,74 @@
|
|||
#ifndef SPROUT_FUNCTIONAL_BIND2ND_HPP
|
||||
#define SPROUT_FUNCTIONAL_BIND2ND_HPP
|
||||
|
||||
#include <type_traits>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/functional/base.hpp>
|
||||
#include <sprout/functional/type_traits/is_strict_function.hpp>
|
||||
|
||||
namespace sprout {
|
||||
// Copyright (C) 2011 RiSK (sscrisk)
|
||||
|
||||
// D.9.3 Class template binder2nd
|
||||
template<typename Fn, typename T = void, typename = void>
|
||||
class binder2nd;
|
||||
template<typename Fn, typename T>
|
||||
class binder2nd<
|
||||
Fn, T,
|
||||
typename std::enable_if<sprout::is_strict_binary_function<Fn>::value>::type
|
||||
>
|
||||
: public sprout::unary_function<typename Fn::first_argument_type, typename Fn::result_type>
|
||||
namespace detail {
|
||||
template<typename Fn, typename T = void, typename = void>
|
||||
class binder2nd;
|
||||
template<typename Fn, typename T>
|
||||
class binder2nd<
|
||||
Fn, T,
|
||||
typename std::enable_if<sprout::is_strict_binary_function<Fn>::value>::type
|
||||
>
|
||||
: public sprout::unary_function<typename Fn::first_argument_type, typename Fn::result_type>
|
||||
{
|
||||
public:
|
||||
typedef typename std::conditional<
|
||||
std::is_void<T>::value,
|
||||
typename Fn::second_argument_type,
|
||||
T
|
||||
>::type value_type;
|
||||
protected:
|
||||
Fn op;
|
||||
value_type value;
|
||||
public:
|
||||
SPROUT_CONSTEXPR binder2nd(Fn const& x, value_type const& y)
|
||||
: op(x), value(y)
|
||||
{}
|
||||
SPROUT_CONSTEXPR typename Fn::result_type
|
||||
operator()(typename Fn::first_argument_type const& x) const {
|
||||
return op(x, value);
|
||||
}
|
||||
};
|
||||
template<typename Fn, typename T>
|
||||
class binder2nd<
|
||||
Fn, T,
|
||||
typename std::enable_if<!sprout::is_strict_binary_function<Fn>::value>::type
|
||||
> {
|
||||
public:
|
||||
typedef T value_type;
|
||||
protected:
|
||||
Fn op;
|
||||
value_type value;
|
||||
public:
|
||||
SPROUT_CONSTEXPR binder2nd(Fn const& x, value_type const& y)
|
||||
: op(x), value(y)
|
||||
{}
|
||||
template<typename U>
|
||||
SPROUT_CONSTEXPR decltype(op(std::declval<U const&>(), value))
|
||||
operator()(U const& x) const {
|
||||
return op(x, value);
|
||||
}
|
||||
};
|
||||
} // namespace detail
|
||||
template<typename Fn, typename T = void>
|
||||
class binder2nd
|
||||
: public sprout::detail::binder2nd<Fn, T>
|
||||
{
|
||||
public:
|
||||
typedef typename std::conditional<
|
||||
std::is_void<T>::value,
|
||||
typename Fn::second_argument_type,
|
||||
T
|
||||
>::type value_type;
|
||||
protected:
|
||||
Fn op;
|
||||
value_type value;
|
||||
typedef typename sprout::detail::binder2nd<Fn, T>::value_type value_type;
|
||||
public:
|
||||
SPROUT_CONSTEXPR binder2nd(Fn const& x, value_type const& y)
|
||||
: op(x), value(y)
|
||||
: sprout::detail::binder2nd<Fn, T>(x, y)
|
||||
{}
|
||||
SPROUT_CONSTEXPR typename Fn::result_type
|
||||
operator()(typename Fn::first_argument_type const& x) const {
|
||||
return op(x, value);
|
||||
}
|
||||
};
|
||||
template<typename Fn, typename T>
|
||||
class binder2nd<
|
||||
Fn, T,
|
||||
typename std::enable_if<!sprout::is_strict_binary_function<Fn>::value>::type
|
||||
> {
|
||||
public:
|
||||
typedef T value_type;
|
||||
protected:
|
||||
Fn op;
|
||||
value_type value;
|
||||
public:
|
||||
SPROUT_CONSTEXPR binder2nd(Fn const& x, value_type const& y)
|
||||
: op(x), value(y)
|
||||
{}
|
||||
template<typename U>
|
||||
SPROUT_CONSTEXPR decltype(op(std::declval<U const&>(), value))
|
||||
operator()(U const& x) const {
|
||||
return op(x, value);
|
||||
}
|
||||
};
|
||||
|
||||
// D.9.3 bind2nd
|
||||
|
|
|
@ -10,36 +10,34 @@
|
|||
#include <sprout/type_traits/enabler_if.hpp>
|
||||
|
||||
namespace sprout {
|
||||
//
|
||||
// hash_value
|
||||
//
|
||||
inline SPROUT_CONSTEXPR std::size_t hash_value(bool v);
|
||||
inline SPROUT_CONSTEXPR std::size_t hash_value(char v);
|
||||
inline SPROUT_CONSTEXPR std::size_t hash_value(unsigned char v);
|
||||
inline SPROUT_CONSTEXPR std::size_t hash_value(signed char v);
|
||||
inline SPROUT_CONSTEXPR std::size_t hash_value(char16_t v);
|
||||
inline SPROUT_CONSTEXPR std::size_t hash_value(char32_t v);
|
||||
inline SPROUT_CONSTEXPR std::size_t hash_value(wchar_t v);
|
||||
inline SPROUT_CONSTEXPR std::size_t hash_value(short v);
|
||||
inline SPROUT_CONSTEXPR std::size_t hash_value(unsigned short v);
|
||||
inline SPROUT_CONSTEXPR std::size_t hash_value(int v);
|
||||
inline SPROUT_CONSTEXPR std::size_t hash_value(unsigned int v);
|
||||
inline SPROUT_CONSTEXPR std::size_t hash_value(long v);
|
||||
inline SPROUT_CONSTEXPR std::size_t hash_value(unsigned long v);
|
||||
inline SPROUT_CONSTEXPR std::size_t hash_value(long long v);
|
||||
inline SPROUT_CONSTEXPR std::size_t hash_value(unsigned long long v);
|
||||
//inline SPROUT_CONSTEXPR std::size_t hash_value(float v);
|
||||
//inline SPROUT_CONSTEXPR std::size_t hash_value(double v);
|
||||
//inline SPROUT_CONSTEXPR std::size_t hash_value(long double v);
|
||||
template<
|
||||
typename T,
|
||||
typename sprout::enabler_if<std::is_pointer<typename std::remove_reference<T>::type>::value>::type
|
||||
>
|
||||
inline SPROUT_CONSTEXPR std::size_t hash_value(T&& v);
|
||||
template<typename T, std::size_t N>
|
||||
inline SPROUT_CONSTEXPR std::size_t hash_value(T const (&v)[N]);
|
||||
|
||||
namespace hash_detail {
|
||||
template <typename T>
|
||||
struct is_basic_number
|
||||
: public std::integral_constant<
|
||||
bool,
|
||||
std::is_integral<T>::value
|
||||
&& (sizeof(T) <= sizeof(std::size_t))
|
||||
>
|
||||
{};
|
||||
template <typename T>
|
||||
struct is_long_number
|
||||
: public std::integral_constant<
|
||||
bool,
|
||||
std::is_integral<T>::value
|
||||
&& (sizeof(T) > sizeof(std::size_t))
|
||||
&& std::is_signed<T>::value
|
||||
>
|
||||
{};
|
||||
template <typename T>
|
||||
struct is_ulong_number
|
||||
: public std::integral_constant<
|
||||
bool,
|
||||
std::is_integral<T>::value
|
||||
&& (sizeof(T) > sizeof(std::size_t))
|
||||
&& std::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) {
|
||||
|
@ -112,71 +110,28 @@ namespace sprout {
|
|||
//
|
||||
// hash_value
|
||||
//
|
||||
inline SPROUT_CONSTEXPR std::size_t
|
||||
hash_value(bool 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(T v) {
|
||||
return static_cast<std::size_t>(v);
|
||||
}
|
||||
inline SPROUT_CONSTEXPR std::size_t
|
||||
hash_value(char v) {
|
||||
return static_cast<std::size_t>(v);
|
||||
}
|
||||
inline SPROUT_CONSTEXPR std::size_t
|
||||
hash_value(unsigned char v) {
|
||||
return static_cast<std::size_t>(v);
|
||||
}
|
||||
inline SPROUT_CONSTEXPR std::size_t
|
||||
hash_value(signed char v) {
|
||||
return static_cast<std::size_t>(v);
|
||||
}
|
||||
inline SPROUT_CONSTEXPR std::size_t
|
||||
hash_value(char16_t v) {
|
||||
return static_cast<std::size_t>(v);
|
||||
}
|
||||
inline SPROUT_CONSTEXPR std::size_t
|
||||
hash_value(char32_t v) {
|
||||
return static_cast<std::size_t>(v);
|
||||
}
|
||||
inline SPROUT_CONSTEXPR std::size_t
|
||||
hash_value(wchar_t v) {
|
||||
return static_cast<std::size_t>(v);
|
||||
}
|
||||
inline SPROUT_CONSTEXPR std::size_t
|
||||
hash_value(short v) {
|
||||
return static_cast<std::size_t>(v);
|
||||
}
|
||||
inline SPROUT_CONSTEXPR std::size_t
|
||||
hash_value(unsigned short v) {
|
||||
return static_cast<std::size_t>(v);
|
||||
}
|
||||
inline SPROUT_CONSTEXPR std::size_t
|
||||
hash_value(int v) {
|
||||
return static_cast<std::size_t>(v);
|
||||
}
|
||||
inline SPROUT_CONSTEXPR std::size_t
|
||||
hash_value(unsigned int v) {
|
||||
return static_cast<std::size_t>(v);
|
||||
}
|
||||
inline SPROUT_CONSTEXPR std::size_t
|
||||
hash_value(long v) {
|
||||
return static_cast<std::size_t>(v);
|
||||
}
|
||||
inline SPROUT_CONSTEXPR std::size_t
|
||||
hash_value(unsigned long v) {
|
||||
return static_cast<std::size_t>(v);
|
||||
}
|
||||
inline SPROUT_CONSTEXPR std::size_t
|
||||
hash_value(long long 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(T v) {
|
||||
return sprout::hash_detail::hash_value_signed(v);
|
||||
}
|
||||
inline SPROUT_CONSTEXPR std::size_t
|
||||
hash_value(unsigned long long 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(T v) {
|
||||
return sprout::hash_detail::hash_value_unsigned(v);
|
||||
}
|
||||
template<
|
||||
typename T,
|
||||
typename sprout::enabler_if<std::is_pointer<typename std::remove_reference<T>::type>::value>::type = sprout::enabler
|
||||
>
|
||||
inline SPROUT_CONSTEXPR std::size_t
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<std::is_enum<T>::value, std::size_t>::type
|
||||
hash_value(T v) {
|
||||
return sprout::hash_value(static_cast<typename std::underlying_type<T>::type>(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(T&& v) {
|
||||
return sprout::hash_detail::hash_value_pointer(v);
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include <sprout/type_traits/has_xxx.hpp>
|
||||
#include <sprout/type_traits/inherit_if_xxx.hpp>
|
||||
#include <sprout/functional/base.hpp>
|
||||
#include <sprout/functional/weak_result_type.hpp>
|
||||
#include <sprout/functional/type_traits/weak_result_type.hpp>
|
||||
|
||||
namespace sprout {
|
||||
// 20.8.3 reference_wrapper
|
||||
|
@ -46,9 +46,9 @@ namespace sprout {
|
|||
template<typename T>
|
||||
struct reference_wrapper_base
|
||||
: public sprout::detail::reference_wrapper_base_impl<
|
||||
sprout::detail::has_argument_type<T>::value,
|
||||
sprout::detail::has_first_argument_type<T>::value
|
||||
&& sprout::detail::has_second_argument_type<T>::value
|
||||
sprout::has_argument_type<T>::value,
|
||||
sprout::has_first_argument_type<T>::value
|
||||
&& sprout::has_second_argument_type<T>::value
|
||||
,
|
||||
T
|
||||
>
|
||||
|
|
|
@ -1,57 +1,10 @@
|
|||
#ifndef SPROUT_FUNCTIONAL_TYPE_TRAITS_HPP
|
||||
#define SPROUT_FUNCTIONAL_TYPE_TRAITS_HPP
|
||||
|
||||
#include <type_traits>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/type_traits/has_xxx.hpp>
|
||||
#include <sprout/type_traits/inherit_if_xxx.hpp>
|
||||
|
||||
namespace sprout {
|
||||
//
|
||||
// has_result_type
|
||||
// has_argument_type
|
||||
// has_first_argument_type
|
||||
// has_second_argument_type
|
||||
//
|
||||
SPROUT_HAS_XXX_TYPE_DEF_LAZY(result_type);
|
||||
SPROUT_HAS_XXX_TYPE_DEF_LAZY(argument_type);
|
||||
SPROUT_HAS_XXX_TYPE_DEF_LAZY(first_argument_type);
|
||||
SPROUT_HAS_XXX_TYPE_DEF_LAZY(second_argument_type);
|
||||
|
||||
//
|
||||
// inhert_if_result_type
|
||||
// inhert_if_argument_type
|
||||
// inhert_if_first_argument_type
|
||||
// inhert_if_second_argument_type
|
||||
//
|
||||
SPROUT_INHERIT_IF_XXX_TYPE_DEF_LAZY(result_type);
|
||||
SPROUT_INHERIT_IF_XXX_TYPE_DEF_LAZY(argument_type);
|
||||
SPROUT_INHERIT_IF_XXX_TYPE_DEF_LAZY(first_argument_type);
|
||||
SPROUT_INHERIT_IF_XXX_TYPE_DEF_LAZY(second_argument_type);
|
||||
|
||||
//
|
||||
// is_strict_unary_function
|
||||
//
|
||||
template<typename Fn>
|
||||
struct is_strict_unary_function
|
||||
: public std::integral_constant<
|
||||
bool,
|
||||
sprout::has_result_type<Fn>::value
|
||||
&& sprout::has_argument_type<Fn>::value
|
||||
>
|
||||
{};
|
||||
//
|
||||
// is_strict_binary_function
|
||||
//
|
||||
template<typename Fn>
|
||||
struct is_strict_binary_function
|
||||
: public std::integral_constant<
|
||||
bool,
|
||||
sprout::has_result_type<Fn>::value
|
||||
&& sprout::has_first_argument_type<Fn>::value
|
||||
&& sprout::has_second_argument_type<Fn>::value
|
||||
>
|
||||
{};
|
||||
} // namespace sprout
|
||||
#include <sprout/functional/type_traits/has_type.hpp>
|
||||
#include <sprout/functional/type_traits/inherit_if_type.hpp>
|
||||
#include <sprout/functional/type_traits/is_strict_function.hpp>
|
||||
#include <sprout/functional/type_traits/weak_result_type.hpp>
|
||||
|
||||
#endif // #ifndef SPROUT_FUNCTIONAL_TYPE_TRAITS_HPP
|
||||
|
|
20
sprout/functional/type_traits/has_type.hpp
Normal file
20
sprout/functional/type_traits/has_type.hpp
Normal file
|
@ -0,0 +1,20 @@
|
|||
#ifndef SPROUT_FUNCTIONAL_TYPE_TRAITS_HAS_TYPE_HPP
|
||||
#define SPROUT_FUNCTIONAL_TYPE_TRAITS_HAS_TYPE_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/type_traits/has_xxx.hpp>
|
||||
|
||||
namespace sprout {
|
||||
//
|
||||
// has_result_type
|
||||
// has_argument_type
|
||||
// has_first_argument_type
|
||||
// has_second_argument_type
|
||||
//
|
||||
SPROUT_HAS_XXX_TYPE_DEF_LAZY(result_type);
|
||||
SPROUT_HAS_XXX_TYPE_DEF_LAZY(argument_type);
|
||||
SPROUT_HAS_XXX_TYPE_DEF_LAZY(first_argument_type);
|
||||
SPROUT_HAS_XXX_TYPE_DEF_LAZY(second_argument_type);
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_FUNCTIONAL_TYPE_TRAITS_HAS_TYPE_HPP
|
20
sprout/functional/type_traits/inherit_if_type.hpp
Normal file
20
sprout/functional/type_traits/inherit_if_type.hpp
Normal file
|
@ -0,0 +1,20 @@
|
|||
#ifndef SPROUT_FUNCTIONAL_TYPE_TRAITS_INHERIT_IF_TYPE_HPP
|
||||
#define SPROUT_FUNCTIONAL_TYPE_TRAITS_INHERIT_IF_TYPE_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/type_traits/inherit_if_xxx.hpp>
|
||||
|
||||
namespace sprout {
|
||||
//
|
||||
// inherit_if_result_type
|
||||
// inherit_if_argument_type
|
||||
// inherit_if_first_argument_type
|
||||
// inherit_if_second_argument_type
|
||||
//
|
||||
SPROUT_INHERIT_IF_XXX_TYPE_DEF_LAZY(result_type);
|
||||
SPROUT_INHERIT_IF_XXX_TYPE_DEF_LAZY(argument_type);
|
||||
SPROUT_INHERIT_IF_XXX_TYPE_DEF_LAZY(first_argument_type);
|
||||
SPROUT_INHERIT_IF_XXX_TYPE_DEF_LAZY(second_argument_type);
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_FUNCTIONAL_TYPE_TRAITS_INHERIT_IF_TYPE_HPP
|
34
sprout/functional/type_traits/is_strict_function.hpp
Normal file
34
sprout/functional/type_traits/is_strict_function.hpp
Normal file
|
@ -0,0 +1,34 @@
|
|||
#ifndef SPROUT_FUNCTIONAL_TYPE_TRAITS_IS_STRICT_FUNCTION_HPP
|
||||
#define SPROUT_FUNCTIONAL_TYPE_TRAITS_IS_STRICT_FUNCTION_HPP
|
||||
|
||||
#include <type_traits>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/functional/type_traits/has_type.hpp>
|
||||
|
||||
namespace sprout {
|
||||
//
|
||||
// is_strict_unary_function
|
||||
//
|
||||
template<typename Fn>
|
||||
struct is_strict_unary_function
|
||||
: public std::integral_constant<
|
||||
bool,
|
||||
sprout::has_result_type<Fn>::value
|
||||
&& sprout::has_argument_type<Fn>::value
|
||||
>
|
||||
{};
|
||||
//
|
||||
// is_strict_binary_function
|
||||
//
|
||||
template<typename Fn>
|
||||
struct is_strict_binary_function
|
||||
: public std::integral_constant<
|
||||
bool,
|
||||
sprout::has_result_type<Fn>::value
|
||||
&& sprout::has_first_argument_type<Fn>::value
|
||||
&& sprout::has_second_argument_type<Fn>::value
|
||||
>
|
||||
{};
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_FUNCTIONAL_TYPE_TRAITS_IS_STRICT_FUNCTION_HPP
|
|
@ -1,38 +1,15 @@
|
|||
#ifndef SPROUT_FUNCTIONAL_WEAK_RESULT_TYPE_HPP
|
||||
#define SPROUT_FUNCTIONAL_WEAK_RESULT_TYPE_HPP
|
||||
#ifndef SPROUT_FUNCTIONAL_TYPE_TRAITS_WEAK_RESULT_TYPE_HPP
|
||||
#define SPROUT_FUNCTIONAL_TYPE_TRAITS_WEAK_RESULT_TYPE_HPP
|
||||
|
||||
#include <type_traits>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/type_traits/has_xxx.hpp>
|
||||
#include <sprout/type_traits/inherit_if_xxx.hpp>
|
||||
#include <sprout/functional/type_traits/inherit_if_type.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace detail {
|
||||
//
|
||||
// has_result_type
|
||||
// has_argument_type
|
||||
// has_first_argument_type
|
||||
// has_second_argument_type
|
||||
//
|
||||
SPROUT_HAS_XXX_TYPE_DEF_LAZY(result_type);
|
||||
SPROUT_HAS_XXX_TYPE_DEF_LAZY(argument_type);
|
||||
SPROUT_HAS_XXX_TYPE_DEF_LAZY(first_argument_type);
|
||||
SPROUT_HAS_XXX_TYPE_DEF_LAZY(second_argument_type);
|
||||
|
||||
//
|
||||
// inherit_if_result_type
|
||||
// inherit_if_argument_type
|
||||
// inherit_if_first_argument_type
|
||||
// inherit_if_second_argument_type
|
||||
//
|
||||
SPROUT_INHERIT_IF_XXX_TYPE_DEF_LAZY(result_type);
|
||||
SPROUT_INHERIT_IF_XXX_TYPE_DEF_LAZY(argument_type);
|
||||
SPROUT_INHERIT_IF_XXX_TYPE_DEF_LAZY(first_argument_type);
|
||||
SPROUT_INHERIT_IF_XXX_TYPE_DEF_LAZY(second_argument_type);
|
||||
|
||||
template<typename F>
|
||||
struct weak_result_type_impl
|
||||
: public sprout::detail::inherit_if_result_type<F>
|
||||
: public sprout::inherit_if_result_type<F>
|
||||
{};
|
||||
template<typename F>
|
||||
struct weak_result_type_impl<F const>
|
||||
|
@ -97,4 +74,4 @@ namespace sprout {
|
|||
{};
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_FUNCTIONAL_WEAK_RESULT_TYPE_HPP
|
||||
#endif // #ifndef SPROUT_FUNCTIONAL_TYPE_TRAITS_WEAK_RESULT_TYPE_HPP
|
Loading…
Add table
Add a link
Reference in a new issue