From b8724c60232a97d1e1785c3c618a340089be9c8a Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 2 Nov 2021 00:49:40 -0600 Subject: [PATCH] [meta] Add in-house impl of hb_is_convertible() --- src/hb-meta.hh | 26 +------------------------- src/test-meta.cc | 14 -------------- 2 files changed, 1 insertion(+), 39 deletions(-) diff --git a/src/hb-meta.hh b/src/hb-meta.hh index 4ec3702bf..0ea5774a9 100644 --- a/src/hb-meta.hh +++ b/src/hb-meta.hh @@ -132,31 +132,7 @@ template using hb_add_pointer = decltype (_hb_try_add_pointer (h /* TODO Add feature-parity to std::decay. */ template using hb_decay = hb_remove_const>; -template -struct hb_is_convertible -{ - private: - static constexpr bool from_void = hb_is_same (void, hb_decay); - static constexpr bool to_void = hb_is_same (void, hb_decay ); - static constexpr bool either_void = from_void || to_void; - static constexpr bool both_void = from_void && to_void; - - static hb_true_type impl2 (typename std::conditional::type); - - template - static auto impl (hb_priority<1>) -> decltype (impl2 (hb_declval (T))); - template - static hb_false_type impl (hb_priority<0>); - public: - static constexpr bool value = both_void || - (!either_void && - decltype (impl::type> (hb_prioritize))::value); -}; -#define hb_is_convertible(From,To) hb_is_convertible::value - -template -using hb_is_base_of = hb_is_convertible *, hb_decay *>; -#define hb_is_base_of(Base,Derived) hb_is_base_of::value +#define hb_is_convertible(From,To) std::is_convertible::value template using hb_is_cr_convertible = hb_bool_constant< diff --git a/src/test-meta.cc b/src/test-meta.cc index 0fb2385af..ae9b56b8b 100644 --- a/src/test-meta.cc +++ b/src/test-meta.cc @@ -81,20 +81,6 @@ main (int argc, char **argv) static_assert (hb_is_convertible (int *, void *), ""); static_assert (!hb_is_convertible (void *, int *), ""); - static_assert (hb_is_base_of (void, void), ""); - static_assert (hb_is_base_of (void, int), ""); - static_assert (!hb_is_base_of (int, void), ""); - - static_assert (hb_is_base_of (int, int), ""); - static_assert (hb_is_base_of (const int, int), ""); - static_assert (hb_is_base_of (int, const int), ""); - - static_assert (hb_is_base_of (X, X), ""); - static_assert (hb_is_base_of (X, Y), ""); - static_assert (hb_is_base_of (const X, Y), ""); - static_assert (hb_is_base_of (X, const Y), ""); - static_assert (!hb_is_base_of (Y, X), ""); - /* TODO Add more meaningful tests. */ return 0;