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 compost {
namespace formats {
//
// normalized_to_pcm_wave
//
namespace detail {
template<typename IntType, typename = void>
struct normalized_to_pcm_wave;
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());
}
};
} // 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
//
@ -69,11 +75,11 @@ namespace sprout {
operator|(Range&& lhs, sprout::compost::formats::as_pcm_wave_forwarder<IntType> const& rhs)
-> decltype(
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)
| 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/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

View file

@ -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

View file

@ -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

View file

@ -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);
}

View file

@ -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
>

View file

@ -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

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
#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

View file

@ -11,12 +11,12 @@
//
#define SPROUT_HAS_XXX_TYPE_DEF(NAME, 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> \
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> \
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) \
SPROUT_HAS_XXX_TYPE_DEF(SPROUT_PP_CAT(has_, TYPE), TYPE)
@ -27,12 +27,12 @@
//
#define SPROUT_HAS_XXX_VALUE_DEF(NAME, 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> \
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> \
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) \
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) \
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 {}; \
template<typename T> \
struct NAME< \
@ -40,7 +40,7 @@
//
#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); \
template<typename T, typename Enable = void> \
template<typename T, typename = void> \
struct NAME {}; \
template<typename T> \
struct NAME< \