[meta] Add integral_constant, true_t -> true_type, false_t -> false_type
This commit is contained in:
parent
38e3a8bd53
commit
61d150c916
|
@ -243,8 +243,8 @@ template<typename Iter, typename Item>
|
||||||
struct hb_is_iterator_of
|
struct hb_is_iterator_of
|
||||||
{
|
{
|
||||||
template <typename Item2 = Item>
|
template <typename Item2 = Item>
|
||||||
static hb_true_t impl (hb_priority<2>, hb_iter_t<Iter, hb_type_identity<Item2>> *);
|
static hb_true_type impl (hb_priority<2>, hb_iter_t<Iter, hb_type_identity<Item2>> *);
|
||||||
static hb_false_t impl (hb_priority<0>, const void *);
|
static hb_false_type impl (hb_priority<0>, const void *);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static constexpr bool value = decltype (impl (hb_prioritize, hb_declval (Iter*)))::value;
|
static constexpr bool value = decltype (impl (hb_prioritize, hb_declval (Iter*)))::value;
|
||||||
|
@ -260,10 +260,10 @@ struct hb_is_iterable
|
||||||
private:
|
private:
|
||||||
|
|
||||||
template <typename U>
|
template <typename U>
|
||||||
static auto impl (hb_priority<1>) -> decltype (hb_declval (U).iter (), hb_true_t ());
|
static auto impl (hb_priority<1>) -> decltype (hb_declval (U).iter (), hb_true_type ());
|
||||||
|
|
||||||
template <typename>
|
template <typename>
|
||||||
static hb_false_t impl (hb_priority<0>);
|
static hb_false_type impl (hb_priority<0>);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static constexpr bool value = decltype (impl<T> (hb_prioritize))::value;
|
static constexpr bool value = decltype (impl<T> (hb_prioritize))::value;
|
||||||
|
@ -278,10 +278,10 @@ struct hb_is_source_of
|
||||||
private:
|
private:
|
||||||
template <typename Iter2 = Iter,
|
template <typename Iter2 = Iter,
|
||||||
hb_enable_if (hb_is_convertible (typename Iter2::item_t, const Item &))>
|
hb_enable_if (hb_is_convertible (typename Iter2::item_t, const Item &))>
|
||||||
static hb_true_t impl (hb_priority<2>);
|
static hb_true_type impl (hb_priority<2>);
|
||||||
template <typename Iter2 = Iter>
|
template <typename Iter2 = Iter>
|
||||||
static auto impl (hb_priority<1>) -> decltype (hb_declval (Iter2) >> hb_declval (Item &), hb_true_t ());
|
static auto impl (hb_priority<1>) -> decltype (hb_declval (Iter2) >> hb_declval (Item &), hb_true_type ());
|
||||||
static hb_false_t impl (hb_priority<0>);
|
static hb_false_type impl (hb_priority<0>);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static constexpr bool value = decltype (impl (hb_prioritize))::value;
|
static constexpr bool value = decltype (impl (hb_prioritize))::value;
|
||||||
|
@ -294,10 +294,10 @@ struct hb_is_sink_of
|
||||||
private:
|
private:
|
||||||
template <typename Iter2 = Iter,
|
template <typename Iter2 = Iter,
|
||||||
hb_enable_if (hb_is_convertible (typename Iter2::item_t, Item &))>
|
hb_enable_if (hb_is_convertible (typename Iter2::item_t, Item &))>
|
||||||
static hb_true_t impl (hb_priority<2>);
|
static hb_true_type impl (hb_priority<2>);
|
||||||
template <typename Iter2 = Iter>
|
template <typename Iter2 = Iter>
|
||||||
static auto impl (hb_priority<1>) -> decltype (hb_declval (Iter2) << hb_declval (Item), hb_true_t ());
|
static auto impl (hb_priority<1>) -> decltype (hb_declval (Iter2) << hb_declval (Item), hb_true_type ());
|
||||||
static hb_false_t impl (hb_priority<0>);
|
static hb_false_type impl (hb_priority<0>);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static constexpr bool value = decltype (impl (hb_prioritize))::value;
|
static constexpr bool value = decltype (impl (hb_prioritize))::value;
|
||||||
|
|
|
@ -45,11 +45,10 @@ template<typename... Ts> using hb_void_tt = typename _hb_void_tt<Ts...>::type;
|
||||||
template<typename Head, typename... Ts> struct _hb_head_tt { typedef Head type; };
|
template<typename Head, typename... Ts> struct _hb_head_tt { typedef Head type; };
|
||||||
template<typename... Ts> using hb_head_tt = typename _hb_head_tt<Ts...>::type;
|
template<typename... Ts> using hb_head_tt = typename _hb_head_tt<Ts...>::type;
|
||||||
|
|
||||||
/* Bool! For when we need to evaluate type-dependent expressions
|
template <typename T, T v> struct hb_integral_constant { static constexpr T value = v; };
|
||||||
* in a template argument. */
|
template <bool b> using hb_bool_constant = hb_integral_constant<bool, b>;
|
||||||
template <bool b> struct hb_bool_constant { static constexpr bool value = b; };
|
using hb_true_type = hb_bool_constant<true>;
|
||||||
typedef hb_bool_constant<true> hb_true_t;
|
using hb_false_type = hb_bool_constant<false>;
|
||||||
typedef hb_bool_constant<false> hb_false_t;
|
|
||||||
|
|
||||||
|
|
||||||
/* Basic type SFINAE. */
|
/* Basic type SFINAE. */
|
||||||
|
@ -60,8 +59,8 @@ template <typename T> struct hb_enable_if<true, T> { typedef T ty
|
||||||
/* Concepts/Requires alias: */
|
/* Concepts/Requires alias: */
|
||||||
#define hb_requires(Cond) hb_enable_if((Cond))
|
#define hb_requires(Cond) hb_enable_if((Cond))
|
||||||
|
|
||||||
template <typename T, typename T2> struct hb_is_same : hb_false_t {};
|
template <typename T, typename T2> struct hb_is_same : hb_false_type {};
|
||||||
template <typename T> struct hb_is_same<T, T> : hb_true_t {};
|
template <typename T> struct hb_is_same<T, T> : hb_true_type {};
|
||||||
#define hb_is_same(T, T2) hb_is_same<T, T2>::value
|
#define hb_is_same(T, T2) hb_is_same<T, T2>::value
|
||||||
|
|
||||||
/* Function overloading SFINAE and priority. */
|
/* Function overloading SFINAE and priority. */
|
||||||
|
@ -145,12 +144,12 @@ struct hb_is_convertible
|
||||||
static constexpr bool either_void = from_void || to_void;
|
static constexpr bool either_void = from_void || to_void;
|
||||||
static constexpr bool both_void = from_void && to_void;
|
static constexpr bool both_void = from_void && to_void;
|
||||||
|
|
||||||
static hb_true_t impl2 (hb_conditional<to_void, int, To>);
|
static hb_true_type impl2 (hb_conditional<to_void, int, To>);
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
static auto impl (hb_priority<1>) -> decltype (impl2 (hb_declval (T)));
|
static auto impl (hb_priority<1>) -> decltype (impl2 (hb_declval (T)));
|
||||||
template <typename T>
|
template <typename T>
|
||||||
static hb_false_t impl (hb_priority<0>);
|
static hb_false_type impl (hb_priority<0>);
|
||||||
public:
|
public:
|
||||||
static constexpr bool value = both_void ||
|
static constexpr bool value = both_void ||
|
||||||
(!either_void &&
|
(!either_void &&
|
||||||
|
|
|
@ -55,7 +55,7 @@ struct _hb_null_size<T, hb_bool_constant<true || sizeof (T::min_size)>>
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct hb_null_size
|
struct hb_null_size
|
||||||
{ enum { value = _hb_null_size<T, hb_true_t>::value }; };
|
{ enum { value = _hb_null_size<T, hb_true_type>::value }; };
|
||||||
#define hb_null_size(T) hb_null_size<T>::value
|
#define hb_null_size(T) hb_null_size<T>::value
|
||||||
|
|
||||||
/* These doesn't belong here, but since is copy/paste from above, put it here. */
|
/* These doesn't belong here, but since is copy/paste from above, put it here. */
|
||||||
|
@ -72,7 +72,7 @@ struct _hb_static_size<T, hb_bool_constant<true || sizeof (T::min_size)>>
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct hb_static_size
|
struct hb_static_size
|
||||||
{ enum { value = _hb_static_size<T, hb_true_t>::value }; };
|
{ enum { value = _hb_static_size<T, hb_true_type>::value }; };
|
||||||
#define hb_static_size(T) hb_static_size<T>::value
|
#define hb_static_size(T) hb_static_size<T>::value
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue