From be42800fc6d90340f843fa03be1bb06b0453e519 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 2 Nov 2021 00:04:18 -0600 Subject: [PATCH] [meta] Use std::is_trivially_... instead of internal copies --- src/hb-meta.hh | 58 ++------------------------------------------- src/hb-open-type.hh | 10 ++++---- src/test-meta.cc | 16 ------------- 3 files changed, 7 insertions(+), 77 deletions(-) diff --git a/src/hb-meta.hh b/src/hb-meta.hh index a714bc2bf..a5cbe48da 100644 --- a/src/hb-meta.hh +++ b/src/hb-meta.hh @@ -29,6 +29,8 @@ #include "hb.hh" +#include + /* * C++ template meta-programming & fundamentals used with them. @@ -355,62 +357,6 @@ using hb_is_move_assignable = hb_is_assignable, hb_add_rvalue_reference>; #define hb_is_move_assignable(T) hb_is_move_assignable::value -/* Trivial versions. */ - -template union hb_trivial { T value; }; - -template -using hb_is_trivially_destructible= hb_is_destructible>; -#define hb_is_trivially_destructible(T) hb_is_trivially_destructible::value - -/* Don't know how to do the following. */ -//template -//using hb_is_trivially_constructible= hb_is_constructible, hb_trivial...>; -//#define hb_is_trivially_constructible(...) hb_is_trivially_constructible<__VA_ARGS__>::value - -template -using hb_is_trivially_default_constructible= hb_is_default_constructible>; -#define hb_is_trivially_default_constructible(T) hb_is_trivially_default_constructible::value - -template -using hb_is_trivially_copy_constructible= hb_is_copy_constructible>; -#define hb_is_trivially_copy_constructible(T) hb_is_trivially_copy_constructible::value - -template -using hb_is_trivially_move_constructible= hb_is_move_constructible>; -#define hb_is_trivially_move_constructible(T) hb_is_trivially_move_constructible::value - -/* Don't know how to do the following. */ -//template -//using hb_is_trivially_assignable= hb_is_assignable, hb_trivial>; -//#define hb_is_trivially_assignable(T,U) hb_is_trivially_assignable::value - -template -using hb_is_trivially_copy_assignable= hb_is_copy_assignable>; -#define hb_is_trivially_copy_assignable(T) hb_is_trivially_copy_assignable::value - -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 - -template -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::value - /* hb_unwrap_type (T) * If T has no T::type, returns T. Otherwise calls itself on T::type recursively. */ diff --git a/src/hb-open-type.hh b/src/hb-open-type.hh index 5199d1c48..129aa868d 100644 --- a/src/hb-open-type.hh +++ b/src/hb-open-type.hh @@ -518,7 +518,7 @@ struct UnsizedArrayOf { TRACE_SANITIZE (this); if (unlikely (!sanitize_shallow (c, count))) return_trace (false); - if (!sizeof... (Ts) && hb_is_trivially_copyable (Type)) return_trace (true); + if (!sizeof... (Ts) && std::is_trivially_copyable::value) return_trace (true); for (unsigned int i = 0; i < count; i++) if (unlikely (!c->dispatch (arrayZ[i], hb_forward (ds)...))) return_trace (false); @@ -707,7 +707,7 @@ struct ArrayOf { TRACE_SANITIZE (this); if (unlikely (!sanitize_shallow (c))) return_trace (false); - if (!sizeof... (Ts) && hb_is_trivially_copyable (Type)) return_trace (true); + if (!sizeof... (Ts) && std::is_trivially_copyable::value) return_trace (true); unsigned int count = len; for (unsigned int i = 0; i < count; i++) if (unlikely (!c->dispatch (arrayZ[i], hb_forward (ds)...))) @@ -835,7 +835,7 @@ struct HeadlessArrayOf { TRACE_SANITIZE (this); if (unlikely (!sanitize_shallow (c))) return_trace (false); - if (!sizeof... (Ts) && hb_is_trivially_copyable (Type)) return_trace (true); + if (!sizeof... (Ts) && std::is_trivially_copyable::value) return_trace (true); unsigned int count = get_length (); for (unsigned int i = 0; i < count; i++) if (unlikely (!c->dispatch (arrayZ[i], hb_forward (ds)...))) @@ -884,7 +884,7 @@ struct ArrayOfM1 { TRACE_SANITIZE (this); if (unlikely (!sanitize_shallow (c))) return_trace (false); - if (!sizeof... (Ts) && hb_is_trivially_copyable (Type)) return_trace (true); + if (!sizeof... (Ts) && std::is_trivially_copyable::value) return_trace (true); unsigned int count = lenM1 + 1; for (unsigned int i = 0; i < count; i++) if (unlikely (!c->dispatch (arrayZ[i], hb_forward (ds)...))) @@ -1070,7 +1070,7 @@ struct VarSizedBinSearchArrayOf { TRACE_SANITIZE (this); if (unlikely (!sanitize_shallow (c))) return_trace (false); - if (!sizeof... (Ts) && hb_is_trivially_copyable (Type)) return_trace (true); + if (!sizeof... (Ts) && std::is_trivially_copyable::value) return_trace (true); unsigned int count = get_length (); for (unsigned int i = 0; i < count; i++) if (unlikely (!(*this)[i].sanitize (c, hb_forward (ds)...))) diff --git a/src/test-meta.cc b/src/test-meta.cc index 9436b9038..a26321565 100644 --- a/src/test-meta.cc +++ b/src/test-meta.cc @@ -108,22 +108,6 @@ main (int argc, char **argv) static_assert (hb_is_constructible (X, Y), ""); static_assert (!hb_is_constructible (Y, X), ""); - static_assert (hb_is_trivially_default_constructible (X), ""); - static_assert (hb_is_trivially_default_constructible (Y), ""); - static_assert (hb_is_trivially_copy_constructible (X), ""); - static_assert (hb_is_trivially_copy_constructible (Y), ""); - static_assert (hb_is_trivially_move_constructible (X), ""); - 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), ""); - - static_assert (hb_is_trivial (int), ""); - static_assert (hb_is_trivial (X), ""); - static_assert (hb_is_trivial (Y), ""); - static_assert (hb_is_signed (hb_unwrap_type (U>>)), ""); static_assert (hb_is_unsigned (hb_unwrap_type (U>>>)), "");