[meta] Add hb_is_trivially_copyable()

This commit is contained in:
Behdad Esfahbod 2019-05-10 22:03:03 -07:00
parent f2398f34c0
commit 7162a97bca
2 changed files with 15 additions and 0 deletions

View File

@ -378,5 +378,16 @@ template <typename T>
using hb_is_trivially_move_assignable= hb_is_move_assignable<hb_trivial<T>>;
#define hb_is_trivially_move_assignable(T) hb_is_trivially_move_assignable<T>::value
template <typename T>
using hb_is_trivially_copyable= hb_bool_constant<
hb_is_trivially_destructible (T) &&
(!hb_is_move_assignable (T) || hb_is_trivially_move_assignable (T)) &&
(!hb_is_move_constructible (T) || hb_is_trivially_move_constructible (T)) &&
(!hb_is_copy_assignable (T) || hb_is_trivially_copy_assignable (T)) &&
(!hb_is_copy_constructible (T) || hb_is_trivially_copy_constructible (T)) &&
true
>;
#define hb_is_trivially_copyable(T) hb_is_trivially_copyable<T>::value
#endif /* HB_META_HH */

View File

@ -115,6 +115,10 @@ main (int argc, char **argv)
static_assert (hb_is_trivially_move_constructible (Y), "");
static_assert (hb_is_trivially_destructible (Y), "");
static_assert (hb_is_trivially_copyable (int), "");
static_assert (hb_is_trivially_copyable (X), "");
static_assert (hb_is_trivially_copyable (Y), "");
/* TODO Add more meaningful tests. */
return 0;