rewrite hash implementation

This commit is contained in:
bolero-MURAKAMI 2012-11-15 11:54:57 +09:00
parent 87ee4f4032
commit d00e971abe
13 changed files with 262 additions and 269 deletions

View file

@ -13,10 +13,7 @@
namespace sprout { namespace sprout {
namespace compost { namespace compost {
namespace formats { namespace detail {
//
// normalized_to_pcm_wave
//
template<typename IntType, typename = void> template<typename IntType, typename = void>
struct normalized_to_pcm_wave; struct normalized_to_pcm_wave;
template<typename IntType> template<typename IntType>
@ -45,7 +42,16 @@ namespace sprout {
return static_cast<result_type>(sprout::clamp((x + 1) / 2, 0, 1) * std::numeric_limits<result_type>::max()); return static_cast<result_type>(sprout::clamp((x + 1) / 2, 0, 1) * std::numeric_limits<result_type>::max());
} }
}; };
} // namespace detail
//
// normalized_to_pcm_wave
//
template<typename IntType>
struct normalized_to_pcm_wave
: public sprout::compost::detail::normalized_to_pcm_wave<IntType>
{};
namespace formats {
// //
// as_pcm_wave_forwarder // as_pcm_wave_forwarder
// //
@ -69,11 +75,11 @@ namespace sprout {
operator|(Range&& lhs, sprout::compost::formats::as_pcm_wave_forwarder<IntType> const& rhs) operator|(Range&& lhs, sprout::compost::formats::as_pcm_wave_forwarder<IntType> const& rhs)
-> decltype( -> decltype(
sprout::forward<Range>(lhs) sprout::forward<Range>(lhs)
| sprout::adaptors::transformed(sprout::compost::formats::normalized_to_pcm_wave<IntType>()) | sprout::adaptors::transformed(sprout::compost::normalized_to_pcm_wave<IntType>())
) )
{ {
return sprout::forward<Range>(lhs) return sprout::forward<Range>(lhs)
| sprout::adaptors::transformed(sprout::compost::formats::normalized_to_pcm_wave<IntType>()) | sprout::adaptors::transformed(sprout::compost::normalized_to_pcm_wave<IntType>())
; ;
} }

View file

@ -12,7 +12,7 @@
#include <sprout/tuple/tuple.hpp> #include <sprout/tuple/tuple.hpp>
#include <sprout/functional/ref.hpp> #include <sprout/functional/ref.hpp>
#include <sprout/functional/mem_fn.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 { namespace sprout {
// 20.8.9 bind // 20.8.9 bind

View file

@ -4,58 +4,71 @@
#include <type_traits> #include <type_traits>
#include <sprout/config.hpp> #include <sprout/config.hpp>
#include <sprout/functional/base.hpp> #include <sprout/functional/base.hpp>
#include <sprout/functional/type_traits.hpp> #include <sprout/functional/type_traits/is_strict_function.hpp>
namespace sprout { namespace sprout {
// Copyright (C) 2011 RiSK (sscrisk) // Copyright (C) 2011 RiSK (sscrisk)
// D.9.1 Class template binder1st // D.9.1 Class template binder1st
template<typename Fn, typename T = void, typename = void> namespace detail {
class binder1st; template<typename Fn, typename T = void, typename = void>
template<typename Fn, typename T> class binder1st;
class binder1st< template<typename Fn, typename T>
Fn, T, class binder1st<
typename std::enable_if<sprout::is_strict_binary_function<Fn>::value>::type 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 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: public:
typedef typename std::conditional< typedef typename sprout::detail::binder1st<Fn, T>::value_type value_type;
std::is_void<T>::value,
typename Fn::first_argument_type,
T
>::type value_type;
protected:
Fn op;
value_type value;
public: public:
SPROUT_CONSTEXPR binder1st(Fn const& x, value_type const& y) 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 // D.9.2 bind1st

View file

@ -1,59 +1,74 @@
#ifndef SPROUT_FUNCTIONAL_BIND2ND_HPP #ifndef SPROUT_FUNCTIONAL_BIND2ND_HPP
#define SPROUT_FUNCTIONAL_BIND2ND_HPP #define SPROUT_FUNCTIONAL_BIND2ND_HPP
#include <type_traits>
#include <sprout/config.hpp> #include <sprout/config.hpp>
#include <sprout/functional/base.hpp> #include <sprout/functional/base.hpp>
#include <sprout/functional/type_traits/is_strict_function.hpp>
namespace sprout { namespace sprout {
// Copyright (C) 2011 RiSK (sscrisk) // Copyright (C) 2011 RiSK (sscrisk)
// D.9.3 Class template binder2nd // D.9.3 Class template binder2nd
template<typename Fn, typename T = void, typename = void> namespace detail {
class binder2nd; template<typename Fn, typename T = void, typename = void>
template<typename Fn, typename T> class binder2nd;
class binder2nd< template<typename Fn, typename T>
Fn, T, class binder2nd<
typename std::enable_if<sprout::is_strict_binary_function<Fn>::value>::type 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 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: public:
typedef typename std::conditional< typedef typename sprout::detail::binder2nd<Fn, T>::value_type value_type;
std::is_void<T>::value,
typename Fn::second_argument_type,
T
>::type value_type;
protected:
Fn op;
value_type value;
public: public:
SPROUT_CONSTEXPR binder2nd(Fn const& x, value_type const& y) 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 // D.9.3 bind2nd

View file

@ -10,36 +10,34 @@
#include <sprout/type_traits/enabler_if.hpp> #include <sprout/type_traits/enabler_if.hpp>
namespace sprout { 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 { 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> template<typename T>
inline SPROUT_CONSTEXPR std::size_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) { 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 // hash_value
// //
inline SPROUT_CONSTEXPR std::size_t template<typename T>
hash_value(bool v) { 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); return static_cast<std::size_t>(v);
} }
inline SPROUT_CONSTEXPR std::size_t template<typename T>
hash_value(char v) { inline SPROUT_CONSTEXPR typename std::enable_if<sprout::hash_detail::is_long_number<T>::value, std::size_t>::type
return static_cast<std::size_t>(v); hash_value(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) {
return sprout::hash_detail::hash_value_signed(v); return sprout::hash_detail::hash_value_signed(v);
} }
inline SPROUT_CONSTEXPR std::size_t template<typename T>
hash_value(unsigned long long v) { 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); return sprout::hash_detail::hash_value_unsigned(v);
} }
template< template<typename T>
typename T, inline SPROUT_CONSTEXPR typename std::enable_if<std::is_enum<T>::value, std::size_t>::type
typename sprout::enabler_if<std::is_pointer<typename std::remove_reference<T>::type>::value>::type = sprout::enabler hash_value(T v) {
> return sprout::hash_value(static_cast<typename std::underlying_type<T>::type>(v));
inline SPROUT_CONSTEXPR std::size_t }
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) { hash_value(T&& v) {
return sprout::hash_detail::hash_value_pointer(v); return sprout::hash_detail::hash_value_pointer(v);
} }

View file

@ -7,7 +7,7 @@
#include <sprout/type_traits/has_xxx.hpp> #include <sprout/type_traits/has_xxx.hpp>
#include <sprout/type_traits/inherit_if_xxx.hpp> #include <sprout/type_traits/inherit_if_xxx.hpp>
#include <sprout/functional/base.hpp> #include <sprout/functional/base.hpp>
#include <sprout/functional/weak_result_type.hpp> #include <sprout/functional/type_traits/weak_result_type.hpp>
namespace sprout { namespace sprout {
// 20.8.3 reference_wrapper // 20.8.3 reference_wrapper
@ -46,9 +46,9 @@ namespace sprout {
template<typename T> template<typename T>
struct reference_wrapper_base struct reference_wrapper_base
: public sprout::detail::reference_wrapper_base_impl< : public sprout::detail::reference_wrapper_base_impl<
sprout::detail::has_argument_type<T>::value, sprout::has_argument_type<T>::value,
sprout::detail::has_first_argument_type<T>::value sprout::has_first_argument_type<T>::value
&& sprout::detail::has_second_argument_type<T>::value && sprout::has_second_argument_type<T>::value
, ,
T T
> >

View file

@ -1,57 +1,10 @@
#ifndef SPROUT_FUNCTIONAL_TYPE_TRAITS_HPP #ifndef SPROUT_FUNCTIONAL_TYPE_TRAITS_HPP
#define SPROUT_FUNCTIONAL_TYPE_TRAITS_HPP #define SPROUT_FUNCTIONAL_TYPE_TRAITS_HPP
#include <type_traits>
#include <sprout/config.hpp> #include <sprout/config.hpp>
#include <sprout/type_traits/has_xxx.hpp> #include <sprout/functional/type_traits/has_type.hpp>
#include <sprout/type_traits/inherit_if_xxx.hpp> #include <sprout/functional/type_traits/inherit_if_type.hpp>
#include <sprout/functional/type_traits/is_strict_function.hpp>
namespace sprout { #include <sprout/functional/type_traits/weak_result_type.hpp>
//
// 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
#endif // #ifndef SPROUT_FUNCTIONAL_TYPE_TRAITS_HPP #endif // #ifndef SPROUT_FUNCTIONAL_TYPE_TRAITS_HPP

View 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

View 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

View 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

View file

@ -1,38 +1,15 @@
#ifndef SPROUT_FUNCTIONAL_WEAK_RESULT_TYPE_HPP #ifndef SPROUT_FUNCTIONAL_TYPE_TRAITS_WEAK_RESULT_TYPE_HPP
#define SPROUT_FUNCTIONAL_WEAK_RESULT_TYPE_HPP #define SPROUT_FUNCTIONAL_TYPE_TRAITS_WEAK_RESULT_TYPE_HPP
#include <type_traits> #include <type_traits>
#include <sprout/config.hpp> #include <sprout/config.hpp>
#include <sprout/type_traits/has_xxx.hpp> #include <sprout/functional/type_traits/inherit_if_type.hpp>
#include <sprout/type_traits/inherit_if_xxx.hpp>
namespace sprout { namespace sprout {
namespace detail { 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> template<typename F>
struct weak_result_type_impl struct weak_result_type_impl
: public sprout::detail::inherit_if_result_type<F> : public sprout::inherit_if_result_type<F>
{}; {};
template<typename F> template<typename F>
struct weak_result_type_impl<F const> struct weak_result_type_impl<F const>
@ -97,4 +74,4 @@ namespace sprout {
{}; {};
} // namespace sprout } // namespace sprout
#endif // #ifndef SPROUT_FUNCTIONAL_WEAK_RESULT_TYPE_HPP #endif // #ifndef SPROUT_FUNCTIONAL_TYPE_TRAITS_WEAK_RESULT_TYPE_HPP

View file

@ -11,12 +11,12 @@
// //
#define SPROUT_HAS_XXX_TYPE_DEF(NAME, TYPE) \ #define SPROUT_HAS_XXX_TYPE_DEF(NAME, TYPE) \
template<typename T, typename = typename T::TYPE> \ template<typename T, typename = typename T::TYPE> \
std::true_type SPROUT_PP_CAT(SPROUT_PP_CAT(sprout_has_xxx_impl_check_type_, TYPE), __LINE__)(int); \ std::true_type SPROUT_PP_CAT(SPROUT_PP_CAT(SPROUT_PP_CAT(sprout_has_xxx_impl_check_type_, TYPE), NAME), __LINE__)(int); \
template<typename T> \ template<typename T> \
std::false_type SPROUT_PP_CAT(SPROUT_PP_CAT(sprout_has_xxx_impl_check_type_, TYPE), __LINE__)(long); \ std::false_type SPROUT_PP_CAT(SPROUT_PP_CAT(SPROUT_PP_CAT(sprout_has_xxx_impl_check_type_, TYPE), NAME), __LINE__)(long); \
template<typename T> \ template<typename T> \
struct NAME \ struct NAME \
: decltype(SPROUT_PP_CAT(SPROUT_PP_CAT(sprout_has_xxx_impl_check_type_, TYPE), __LINE__)<T>(0)) \ : decltype(SPROUT_PP_CAT(SPROUT_PP_CAT(SPROUT_PP_CAT(sprout_has_xxx_impl_check_type_, TYPE), NAME), __LINE__)<T>(0)) \
{} {}
#define SPROUT_HAS_XXX_TYPE_DEF_LAZY(TYPE) \ #define SPROUT_HAS_XXX_TYPE_DEF_LAZY(TYPE) \
SPROUT_HAS_XXX_TYPE_DEF(SPROUT_PP_CAT(has_, TYPE), TYPE) SPROUT_HAS_XXX_TYPE_DEF(SPROUT_PP_CAT(has_, TYPE), TYPE)
@ -27,12 +27,12 @@
// //
#define SPROUT_HAS_XXX_VALUE_DEF(NAME, VALUE) \ #define SPROUT_HAS_XXX_VALUE_DEF(NAME, VALUE) \
template<typename T, decltype(&T::VALUE) = &T::VALUE> \ template<typename T, decltype(&T::VALUE) = &T::VALUE> \
std::true_type SPROUT_PP_CAT(SPROUT_PP_CAT(sprout_has_xxx_impl_check_value_, VALUE), __LINE__)(int); \ std::true_type SPROUT_PP_CAT(SPROUT_PP_CAT(SPROUT_PP_CAT(sprout_has_xxx_impl_check_value_, VALUE), NAME), __LINE__)(int); \
template<typename T> \ template<typename T> \
std::false_type SPROUT_PP_CAT(SPROUT_PP_CAT(sprout_has_xxx_impl_check_value_, VALUE), __LINE__)(long); \ std::false_type SPROUT_PP_CAT(SPROUT_PP_CAT(SPROUT_PP_CAT(sprout_has_xxx_impl_check_value_, VALUE), NAME), __LINE__)(long); \
template<typename T> \ template<typename T> \
struct NAME \ struct NAME \
: decltype(SPROUT_PP_CAT(SPROUT_PP_CAT(sprout_has_xxx_impl_check_value_, VALUE), __LINE__)<T>(0)) \ : decltype(SPROUT_PP_CAT(SPROUT_PP_CAT(SPROUT_PP_CAT(sprout_has_xxx_impl_check_value_, VALUE), NAME), __LINE__)<T>(0)) \
{} {}
#define SPROUT_HAS_XXX_VALUE_DEF_LAZY(VALUE) \ #define SPROUT_HAS_XXX_VALUE_DEF_LAZY(VALUE) \
SPROUT_HAS_XXX_VALUE_DEF(SPROUT_PP_CAT(has_, VALUE), VALUE) SPROUT_HAS_XXX_VALUE_DEF(SPROUT_PP_CAT(has_, VALUE), VALUE)

View file

@ -12,7 +12,7 @@
// //
#define SPROUT_INHERIT_ALIAS_IF_XXX_TYPE_DEF(NAME, ALIAS, TYPE) \ #define SPROUT_INHERIT_ALIAS_IF_XXX_TYPE_DEF(NAME, ALIAS, TYPE) \
SPROUT_HAS_XXX_TYPE_DEF(SPROUT_PP_CAT(SPROUT_PP_CAT(sprout_inherit_if_xxx_type_def_impl_has_, TYPE), __LINE__), TYPE); \ SPROUT_HAS_XXX_TYPE_DEF(SPROUT_PP_CAT(SPROUT_PP_CAT(sprout_inherit_if_xxx_type_def_impl_has_, TYPE), __LINE__), TYPE); \
template<typename T, typename Enable = void> \ template<typename T, typename = void> \
struct NAME {}; \ struct NAME {}; \
template<typename T> \ template<typename T> \
struct NAME< \ struct NAME< \
@ -40,7 +40,7 @@
// //
#define SPROUT_INHERIT_ALIAS_IF_XXX_CONSTANT_DEF(NAME, ALIAS, CONSTANT) \ #define SPROUT_INHERIT_ALIAS_IF_XXX_CONSTANT_DEF(NAME, ALIAS, CONSTANT) \
SPROUT_HAS_XXX_VALUE_DEF(SPROUT_PP_CAT(SPROUT_PP_CAT(sprout_inherit_if_xxx_constant_def_impl_has_, CONSTANT), __LINE__), CONSTANT); \ SPROUT_HAS_XXX_VALUE_DEF(SPROUT_PP_CAT(SPROUT_PP_CAT(sprout_inherit_if_xxx_constant_def_impl_has_, CONSTANT), __LINE__), CONSTANT); \
template<typename T, typename Enable = void> \ template<typename T, typename = void> \
struct NAME {}; \ struct NAME {}; \
template<typename T> \ template<typename T> \
struct NAME< \ struct NAME< \