From 69d9114b5372c1fcea5f20e75a187158c31c52f8 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Thu, 9 May 2019 15:24:14 -0700 Subject: [PATCH] [meta] Rewrite hb_is_cr_converitble --- src/hb-meta.hh | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/hb-meta.hh b/src/hb-meta.hh index b906c5539..58852091f 100644 --- a/src/hb-meta.hh +++ b/src/hb-meta.hh @@ -116,18 +116,6 @@ template using hb_remove_pointer = typename hb_match_pointer::ty /* TODO Add feature-parity to std::decay. */ template using hb_decay = hb_remove_const>; -#define hb_is_cr_convertible(From, To) \ - ( \ - hb_is_same (hb_decay, hb_decay) && \ - ( \ - hb_is_const (From) <= hb_is_const (To) && \ - hb_is_reference (From) >= hb_is_reference (To) \ - ) || ( \ - hb_is_const (To) && hb_is_reference (To) \ - ) \ - ) - - template struct _hb_conditional { typedef T type; }; @@ -159,6 +147,16 @@ struct hb_is_convertible }; #define hb_is_convertible(From,To) hb_is_convertible::value +template +struct hb_is_cr_convertible +{ + public: + static constexpr bool value = + hb_is_same (hb_decay, hb_decay) && + (!hb_is_const (From) || hb_is_const (To)) && + (!hb_is_reference (To) || hb_is_const (To) || hb_is_reference (To)); +}; +#define hb_is_cr_convertible(From,To) hb_is_cr_convertible::value /* std::move and std::forward */