From: Behdad Esfahbod Date: Sat, 11 May 2019 03:06:31 +0000 (-0700) Subject: [meta] Add integral_constant, true_t -> true_type, false_t -> false_type X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=61d150c916d181cc3f333d0378108e08210370ad;p=platform%2Fupstream%2FlibHarfBuzzSharp.git [meta] Add integral_constant, true_t -> true_type, false_t -> false_type --- diff --git a/src/hb-iter.hh b/src/hb-iter.hh index cdc4fdc..a0beb2c 100644 --- a/src/hb-iter.hh +++ b/src/hb-iter.hh @@ -243,8 +243,8 @@ template struct hb_is_iterator_of { template - static hb_true_t impl (hb_priority<2>, hb_iter_t> *); - static hb_false_t impl (hb_priority<0>, const void *); + static hb_true_type impl (hb_priority<2>, hb_iter_t> *); + static hb_false_type impl (hb_priority<0>, const void *); public: static constexpr bool value = decltype (impl (hb_prioritize, hb_declval (Iter*)))::value; @@ -260,10 +260,10 @@ struct hb_is_iterable private: template - 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 - static hb_false_t impl (hb_priority<0>); + static hb_false_type impl (hb_priority<0>); public: static constexpr bool value = decltype (impl (hb_prioritize))::value; @@ -278,10 +278,10 @@ struct hb_is_source_of private: template - static hb_true_t impl (hb_priority<2>); + static hb_true_type impl (hb_priority<2>); template - static auto impl (hb_priority<1>) -> decltype (hb_declval (Iter2) >> hb_declval (Item &), hb_true_t ()); - static hb_false_t impl (hb_priority<0>); + static auto impl (hb_priority<1>) -> decltype (hb_declval (Iter2) >> hb_declval (Item &), hb_true_type ()); + static hb_false_type impl (hb_priority<0>); public: static constexpr bool value = decltype (impl (hb_prioritize))::value; @@ -294,10 +294,10 @@ struct hb_is_sink_of private: template - static hb_true_t impl (hb_priority<2>); + static hb_true_type impl (hb_priority<2>); template - static auto impl (hb_priority<1>) -> decltype (hb_declval (Iter2) << hb_declval (Item), hb_true_t ()); - static hb_false_t impl (hb_priority<0>); + static auto impl (hb_priority<1>) -> decltype (hb_declval (Iter2) << hb_declval (Item), hb_true_type ()); + static hb_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 e5eae56..f009245 100644 --- a/src/hb-meta.hh +++ b/src/hb-meta.hh @@ -45,11 +45,10 @@ template using hb_void_tt = typename _hb_void_tt::type; template struct _hb_head_tt { typedef Head type; }; template using hb_head_tt = typename _hb_head_tt::type; -/* Bool! For when we need to evaluate type-dependent expressions - * in a template argument. */ -template struct hb_bool_constant { static constexpr bool value = b; }; -typedef hb_bool_constant hb_true_t; -typedef hb_bool_constant hb_false_t; +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; /* Basic type SFINAE. */ @@ -60,8 +59,8 @@ template struct hb_enable_if { typedef T ty /* Concepts/Requires alias: */ #define hb_requires(Cond) hb_enable_if((Cond)) -template struct hb_is_same : hb_false_t {}; -template struct hb_is_same : hb_true_t {}; +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 /* 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 both_void = from_void && to_void; - static hb_true_t impl2 (hb_conditional); + static hb_true_type impl2 (hb_conditional); template static auto impl (hb_priority<1>) -> decltype (impl2 (hb_declval (T))); template - static hb_false_t impl (hb_priority<0>); + static hb_false_type impl (hb_priority<0>); public: static constexpr bool value = both_void || (!either_void && diff --git a/src/hb-null.hh b/src/hb-null.hh index fea881a..79da715 100644 --- a/src/hb-null.hh +++ b/src/hb-null.hh @@ -55,7 +55,7 @@ struct _hb_null_size> template struct hb_null_size -{ enum { value = _hb_null_size::value }; }; +{ enum { value = _hb_null_size::value }; }; #define hb_null_size(T) hb_null_size::value /* These doesn't belong here, but since is copy/paste from above, put it here. */ @@ -72,7 +72,7 @@ struct _hb_static_size> template struct hb_static_size -{ enum { value = _hb_static_size::value }; }; +{ enum { value = _hb_static_size::value }; }; #define hb_static_size(T) hb_static_size::value