From 7162a97bca6e0dde3d277701a3bf15688deef61d Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 10 May 2019 22:03:03 -0700 Subject: [PATCH] [meta] Add hb_is_trivially_copyable() --- src/hb-meta.hh | 11 +++++++++++ src/test-meta.cc | 4 ++++ 2 files changed, 15 insertions(+) diff --git a/src/hb-meta.hh b/src/hb-meta.hh index f69a567c2..a1e93d750 100644 --- a/src/hb-meta.hh +++ b/src/hb-meta.hh @@ -378,5 +378,16 @@ template using hb_is_trivially_move_assignable= hb_is_move_assignable>; #define hb_is_trivially_move_assignable(T) hb_is_trivially_move_assignable::value +template +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::value + #endif /* HB_META_HH */ diff --git a/src/test-meta.cc b/src/test-meta.cc index ab7f6ad11..f03be3064 100644 --- a/src/test-meta.cc +++ b/src/test-meta.cc @@ -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;