[meta] Rewrite hb_is_cr_converitble

This commit is contained in:
Behdad Esfahbod 2019-05-09 15:24:14 -07:00
parent ceda1f03b7
commit 69d9114b53
1 changed files with 10 additions and 12 deletions

View File

@ -116,18 +116,6 @@ template <typename T> using hb_remove_pointer = typename hb_match_pointer<T>::ty
/* TODO Add feature-parity to std::decay. */
template <typename T> using hb_decay = hb_remove_const<hb_remove_reference<T>>;
#define hb_is_cr_convertible(From, To) \
( \
hb_is_same (hb_decay<From>, hb_decay<To>) && \
( \
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<bool B, class T, class F>
struct _hb_conditional { typedef T type; };
@ -159,6 +147,16 @@ struct hb_is_convertible
};
#define hb_is_convertible(From,To) hb_is_convertible<From, To>::value
template <typename From, typename To>
struct hb_is_cr_convertible
{
public:
static constexpr bool value =
hb_is_same (hb_decay<From>, hb_decay<To>) &&
(!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<From, To>::value
/* std::move and std::forward */