diff --git a/src/hb-iter.hh b/src/hb-iter.hh index 242058cbf..40cb4943d 100644 --- a/src/hb-iter.hh +++ b/src/hb-iter.hh @@ -256,8 +256,8 @@ template struct hb_is_iterator_of { template - static hb_true_type impl (hb_priority<2>, hb_iter_t> *); - static hb_false_type impl (hb_priority<0>, const void *); + static std::true_type impl (hb_priority<2>, hb_iter_t> *); + static std::false_type impl (hb_priority<0>, const void *); public: static constexpr bool value = decltype (impl (hb_prioritize, hb_declval (Iter*)))::value; @@ -275,10 +275,10 @@ struct hb_is_iterable private: template - static auto impl (hb_priority<1>) -> decltype (hb_declval (U).iter (), hb_true_type ()); + static auto impl (hb_priority<1>) -> decltype (hb_declval (U).iter (), std::true_type ()); template - static hb_false_type impl (hb_priority<0>); + static std::false_type impl (hb_priority<0>); public: static constexpr bool value = decltype (impl (hb_prioritize))::value; @@ -293,10 +293,10 @@ struct hb_is_source_of private: template ))> - static hb_true_type impl (hb_priority<2>); + static std::true_type impl (hb_priority<2>); template - static auto impl (hb_priority<1>) -> decltype (hb_declval (Iter2) >> hb_declval (Item &), hb_true_type ()); - static hb_false_type impl (hb_priority<0>); + static auto impl (hb_priority<1>) -> decltype (hb_declval (Iter2) >> hb_declval (Item &), std::true_type ()); + static std::false_type impl (hb_priority<0>); public: static constexpr bool value = decltype (impl (hb_prioritize))::value; @@ -309,10 +309,10 @@ struct hb_is_sink_of private: template ))> - static hb_true_type impl (hb_priority<2>); + static std::true_type impl (hb_priority<2>); template - static auto impl (hb_priority<1>) -> decltype (hb_declval (Iter2) << hb_declval (Item), hb_true_type ()); - static hb_false_type impl (hb_priority<0>); + static auto impl (hb_priority<1>) -> decltype (hb_declval (Iter2) << hb_declval (Item), std::true_type ()); + static std::false_type impl (hb_priority<0>); public: static constexpr bool value = decltype (impl (hb_prioritize))::value; diff --git a/src/hb-meta.hh b/src/hb-meta.hh index 52ff4a841..46489fa42 100644 --- a/src/hb-meta.hh +++ b/src/hb-meta.hh @@ -29,6 +29,7 @@ #include "hb.hh" +#include #include #include #include @@ -48,27 +49,18 @@ template using hb_void_t = typename _hb_void_t::type; template struct _hb_head_t { typedef Head type; }; template using hb_head_t = typename _hb_head_t::type; -template struct hb_integral_constant { static constexpr T value = v; }; -template using hb_bool_constant = hb_integral_constant; -using hb_true_type = hb_bool_constant; -using hb_false_type = hb_bool_constant; - /* Static-assert as expression. */ template struct static_assert_expr; -template <> struct static_assert_expr : hb_false_type {}; +template <> struct static_assert_expr : std::false_type {}; #define static_assert_expr(C) static_assert_expr::value /* Basic type SFINAE. */ -template struct hb_enable_if {}; -template struct hb_enable_if { typedef T type; }; -#define hb_enable_if(Cond) typename hb_enable_if<(Cond)>::type* = nullptr +#define hb_enable_if(Cond) typename std::enable_if<(Cond)>::type* = nullptr /* Concepts/Requires alias: */ #define hb_requires(Cond) hb_enable_if((Cond)) -template struct hb_is_same : hb_false_type {}; -template struct hb_is_same : hb_true_type {}; -#define hb_is_same(T, T2) hb_is_same::value +#define hb_is_same(T, T2) std::is_same::value /* Function overloading SFINAE and priority. */ @@ -89,27 +81,16 @@ template using hb_type_identity = typename hb_type_identity_t::t template static inline T hb_declval (); #define hb_declval(T) (hb_declval ()) -template struct hb_match_const : hb_type_identity_t, hb_false_type {}; -template struct hb_match_const : hb_type_identity_t, hb_true_type {}; -template using hb_remove_const = typename hb_match_const::type; +template using hb_remove_const = typename std::remove_const::type; -template struct hb_match_reference : hb_type_identity_t, hb_false_type {}; -template struct hb_match_reference : hb_type_identity_t, hb_true_type {}; -template struct hb_match_reference : hb_type_identity_t, hb_true_type {}; -template using hb_remove_reference = typename hb_match_reference::type; +template using hb_remove_reference = typename std::remove_reference::type; template auto _hb_try_add_lvalue_reference (hb_priority<1>) -> hb_type_identity; template auto _hb_try_add_lvalue_reference (hb_priority<0>) -> hb_type_identity; template using hb_add_lvalue_reference = decltype (_hb_try_add_lvalue_reference (hb_prioritize)); -template auto _hb_try_add_rvalue_reference (hb_priority<1>) -> hb_type_identity; -template auto _hb_try_add_rvalue_reference (hb_priority<0>) -> hb_type_identity; -template using hb_add_rvalue_reference = decltype (_hb_try_add_rvalue_reference (hb_prioritize)); -template struct hb_match_pointer : hb_type_identity_t, hb_false_type {}; -template struct hb_match_pointer : hb_type_identity_t, hb_true_type {}; +template struct hb_match_pointer : std::false_type { typedef T type; }; +template struct hb_match_pointer : std::true_type { typedef T type; }; template using hb_remove_pointer = typename hb_match_pointer::type; -template auto _hb_try_add_pointer (hb_priority<1>) -> hb_type_identity*>; -template auto _hb_try_add_pointer (hb_priority<1>) -> hb_type_identity; -template using hb_add_pointer = decltype (_hb_try_add_pointer (hb_prioritize)); template using hb_decay = typename std::decay::type; @@ -117,7 +98,7 @@ template using hb_decay = typename std::decay::type; #define hb_is_convertible(From,To) std::is_convertible::value template -using hb_is_cr_convertible = hb_bool_constant< +using hb_is_cr_convertible = std::integral_constant, hb_decay) && (!std::is_const::value || std::is_const::value) && (!std::is_reference::value || std::is_const::value || std::is_reference::value) @@ -171,32 +152,18 @@ struct hb_reference_wrapper /* Type traits */ -template struct hb_int_min; -template <> struct hb_int_min : hb_integral_constant {}; -template <> struct hb_int_min : hb_integral_constant {}; -template <> struct hb_int_min : hb_integral_constant {}; -template <> struct hb_int_min : hb_integral_constant {}; -template <> struct hb_int_min : hb_integral_constant {}; -template <> struct hb_int_min : hb_integral_constant {}; -template <> struct hb_int_min : hb_integral_constant {}; -template <> struct hb_int_min : hb_integral_constant {}; -template <> struct hb_int_min : hb_integral_constant {}; -template <> struct hb_int_min : hb_integral_constant {}; -template <> struct hb_int_min : hb_integral_constant {}; -template struct hb_int_min : hb_integral_constant {}; +template +struct hb_int_min : std::integral_constant::min) ()> +{ + static_assert (std::is_integral::value, ""); +}; +template struct hb_int_min : std::integral_constant {}; #define hb_int_min(T) hb_int_min::value -template struct hb_int_max; -template <> struct hb_int_max : hb_integral_constant {}; -template <> struct hb_int_max : hb_integral_constant {}; -template <> struct hb_int_max : hb_integral_constant {}; -template <> struct hb_int_max : hb_integral_constant {}; -template <> struct hb_int_max : hb_integral_constant {}; -template <> struct hb_int_max : hb_integral_constant {}; -template <> struct hb_int_max : hb_integral_constant {}; -template <> struct hb_int_max : hb_integral_constant {}; -template <> struct hb_int_max : hb_integral_constant {}; -template <> struct hb_int_max : hb_integral_constant {}; -template <> struct hb_int_max : hb_integral_constant {}; +template +struct hb_int_max : std::integral_constant::max) ()> +{ + static_assert (std::is_integral::value, ""); +}; #define hb_int_max(T) hb_int_max::value #if defined(__GNUC__) && __GNUC__ < 5 && !defined(__clang__) diff --git a/src/hb-null.hh b/src/hb-null.hh index 3588f6ab2..f33f0025c 100644 --- a/src/hb-null.hh +++ b/src/hb-null.hh @@ -40,19 +40,19 @@ #define HB_NULL_POOL_SIZE 640 template -struct _hb_has_min_size : hb_false_type {}; +struct _hb_has_min_size : std::false_type {}; template struct _hb_has_min_size> - : hb_true_type {}; + : std::true_type {}; template using hb_has_min_size = _hb_has_min_size; #define hb_has_min_size(T) hb_has_min_size::value template -struct _hb_has_null_size : hb_false_type {}; +struct _hb_has_null_size : std::false_type {}; template struct _hb_has_null_size> - : hb_true_type {}; + : std::true_type {}; template using hb_has_null_size = _hb_has_null_size; #define hb_has_null_size(T) hb_has_null_size::value @@ -68,10 +68,10 @@ using hb_has_null_size = _hb_has_null_size; */ template -struct _hb_null_size : hb_integral_constant {}; +struct _hb_null_size : std::integral_constant {}; template struct _hb_null_size> - : hb_integral_constant T::null_size ? sizeof (T) : T::null_size)> {}; template using hb_null_size = _hb_null_size; @@ -83,17 +83,17 @@ using hb_null_size = _hb_null_size; * Returns T::static_size if T::min_size is defined, or sizeof (T) otherwise. */ template -struct _hb_static_size : hb_integral_constant {}; +struct _hb_static_size : std::integral_constant {}; template -struct _hb_static_size> : hb_integral_constant {}; +struct _hb_static_size> : std::integral_constant {}; template using hb_static_size = _hb_static_size; #define hb_static_size(T) hb_static_size::value template -struct _hb_min_size : hb_integral_constant {}; +struct _hb_min_size : std::integral_constant {}; template -struct _hb_min_size> : hb_integral_constant {}; +struct _hb_min_size> : std::integral_constant {}; template using hb_min_size = _hb_min_size; #define hb_min_size(T) hb_min_size::value diff --git a/src/hb-result.hh b/src/hb-result.hh index f142c992c..2774b8ee3 100644 --- a/src/hb-result.hh +++ b/src/hb-result.hh @@ -51,9 +51,9 @@ struct hb_result_err_t constexpr bool operator != (const hb_result_err_t& other) const { return error != other.error; } }; -template struct _hb_is_result_tag : hb_false_type {}; -template struct _hb_is_result_tag> : hb_true_type {}; -template struct _hb_is_result_tag> : hb_true_type {}; +template struct _hb_is_result_tag : std::false_type {}; +template struct _hb_is_result_tag> : std::true_type {}; +template struct _hb_is_result_tag> : std::true_type {}; template static inline constexpr hb_result_ok_t Ok (T&& v)