[meta] Add hb_is_trivial
authorBehdad Esfahbod <behdad@behdad.org>
Sat, 11 May 2019 05:04:40 +0000 (22:04 -0700)
committerBehdad Esfahbod <behdad@behdad.org>
Sat, 11 May 2019 05:04:40 +0000 (22:04 -0700)
src/hb-meta.hh
src/test-meta.cc

index a1e93d7..df8ebd1 100644 (file)
@@ -389,5 +389,12 @@ using hb_is_trivially_copyable= hb_bool_constant<
 >;
 #define hb_is_trivially_copyable(T) hb_is_trivially_copyable<T>::value
 
+template <typename T>
+using hb_is_trivial= hb_bool_constant<
+  hb_is_trivially_copyable (T) &&
+  hb_is_trivially_default_constructible (T)
+>;
+#define hb_is_trivial(T) hb_is_trivial<T>::value
+
 
 #endif /* HB_META_HH */
index f03be30..ffd360b 100644 (file)
@@ -119,6 +119,10 @@ main (int argc, char **argv)
   static_assert (hb_is_trivially_copyable (X), "");
   static_assert (hb_is_trivially_copyable (Y), "");
 
+  static_assert (hb_is_trivial (int), "");
+  static_assert (hb_is_trivial (X), "");
+  static_assert (hb_is_trivial (Y), "");
+
   /* TODO Add more meaningful tests. */
 
   return 0;