m Move static_assert_expr<>

This commit is contained in:
Behdad Esfahbod 2020-06-29 00:44:41 -07:00
parent 61f8d0e57d
commit 017f6b0d24
2 changed files with 4 additions and 5 deletions

View File

@ -49,6 +49,10 @@ template <bool b> using hb_bool_constant = hb_integral_constant<bool, b>;
using hb_true_type = hb_bool_constant<true>;
using hb_false_type = hb_bool_constant<false>;
/* Static-assert as expression. */
template <bool cond> struct static_assert_expr;
template <> struct static_assert_expr<true> : hb_false_type {};
#define static_assert_expr(C) static_assert_expr<C>::value
/* Basic type SFINAE. */

View File

@ -441,11 +441,6 @@ static int HB_UNUSED _hb_errno = 0;
#define HB_STMT_START do
#define HB_STMT_END while (0)
/* Static-assert as expression. */
template <bool cond> class hb_assert_constant_t;
template <> class hb_assert_constant_t<true> {};
#define static_assert_expr(_cond) (bool (0u * (unsigned int) sizeof (hb_assert_constant_t<_cond>)))
/* Lets assert int types. Saves trouble down the road. */
static_assert ((sizeof (int8_t) == 1), "");
static_assert ((sizeof (uint8_t) == 1), "");