about summary refs log tree commit diff
path: root/absl/meta/type_traits.h
diff options
context:
space:
mode:
Diffstat (limited to 'absl/meta/type_traits.h')
-rw-r--r--absl/meta/type_traits.h66
1 files changed, 44 insertions, 22 deletions
diff --git a/absl/meta/type_traits.h b/absl/meta/type_traits.h
index 6f7138c2d8..f36a59aa77 100644
--- a/absl/meta/type_traits.h
+++ b/absl/meta/type_traits.h
@@ -148,11 +148,16 @@ struct negation : std::integral_constant<bool, !T::value> {};
 template <typename T>
 struct is_trivially_destructible
     : std::integral_constant<bool, __has_trivial_destructor(T) &&
-                                       std::is_destructible<T>::value> {
+                                   std::is_destructible<T>::value> {
 #ifdef ABSL_HAVE_STD_IS_TRIVIALLY_DESTRUCTIBLE
-  static_assert(std::is_trivially_destructible<T>::value ==
-                    is_trivially_destructible::value,
-                "Not compliant with std::is_trivially_destructible");
+  static constexpr bool compliant = std::is_trivially_destructible<T>::value ==
+                                    is_trivially_destructible::value;
+  static_assert(compliant || std::is_trivially_destructible<T>::value,
+                "Not compliant with std::is_trivially_destructible; "
+                "Standard: false, Implementation: true");
+  static_assert(compliant || !std::is_trivially_destructible<T>::value,
+                "Not compliant with std::is_trivially_destructible; "
+                "Standard: true, Implementation: false");
 #endif  // ABSL_HAVE_STD_IS_TRIVIALLY_DESTRUCTIBLE
 };
 
@@ -186,18 +191,23 @@ struct is_trivially_destructible
 // GCC bug 51452: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51452
 // LWG issue 2116: http://cplusplus.github.io/LWG/lwg-active.html#2116.
 //
-// "T obj();" need to be well-formed and not call any non-trivial operation.
+// "T obj();" need to be well-formed and not call any nontrivial operation.
 // Nontrivally destructible types will cause the expression to be nontrivial.
 template <typename T>
 struct is_trivially_default_constructible
-    : std::integral_constant<bool,
-                             __has_trivial_constructor(T) &&
-                                 std::is_default_constructible<T>::value &&
-                                 is_trivially_destructible<T>::value> {
+    : std::integral_constant<bool, __has_trivial_constructor(T) &&
+                                   std::is_default_constructible<T>::value &&
+                                   is_trivially_destructible<T>::value> {
 #ifdef ABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE
-  static_assert(std::is_trivially_default_constructible<T>::value ==
-                    is_trivially_default_constructible::value,
-                "Not compliant with std::is_trivially_default_constructible");
+  static constexpr bool compliant =
+      std::is_trivially_default_constructible<T>::value ==
+      is_trivially_default_constructible::value;
+  static_assert(compliant || std::is_trivially_default_constructible<T>::value,
+                "Not compliant with std::is_trivially_default_constructible; "
+                "Standard: false, Implementation: true");
+  static_assert(compliant || !std::is_trivially_default_constructible<T>::value,
+                "Not compliant with std::is_trivially_default_constructible; "
+                "Standard: true, Implementation: false");
 #endif  // ABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE
 };
 
@@ -217,12 +227,18 @@ struct is_trivially_default_constructible
 template <typename T>
 struct is_trivially_copy_constructible
     : std::integral_constant<bool, __has_trivial_copy(T) &&
-                                       std::is_copy_constructible<T>::value &&
-                                       is_trivially_destructible<T>::value> {
+                                   std::is_copy_constructible<T>::value &&
+                                   is_trivially_destructible<T>::value> {
 #ifdef ABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE
-  static_assert(std::is_trivially_copy_constructible<T>::value ==
-                    is_trivially_copy_constructible::value,
-                "Not compliant with std::is_trivially_copy_constructible");
+  static constexpr bool compliant =
+      std::is_trivially_copy_constructible<T>::value ==
+      is_trivially_copy_constructible::value;
+  static_assert(compliant || std::is_trivially_copy_constructible<T>::value,
+                "Not compliant with std::is_trivially_copy_constructible; "
+                "Standard: false, Implementation: true");
+  static_assert(compliant || !std::is_trivially_copy_constructible<T>::value,
+                "Not compliant with std::is_trivially_copy_constructible; "
+                "Standard: true, Implementation: false");
 #endif  // ABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE
 };
 
@@ -240,15 +256,21 @@ struct is_trivially_copy_constructible
 // `declval<T>() = declval<U>()` is well-formed when treated as an unevaluated
 // operand. `is_trivially_assignable<T, U>` requires the assignment to call no
 // operation that is not trivial. `is_trivially_copy_assignable<T>` is simply
-// `is_trivially_assignable<T, const T&>`.
+// `is_trivially_assignable<T&, const T&>`.
 template <typename T>
 struct is_trivially_copy_assignable
     : std::integral_constant<bool, __has_trivial_assign(T) &&
-                                       std::is_copy_assignable<T>::value> {
+                                   std::is_copy_assignable<T>::value> {
 #ifdef ABSL_HAVE_STD_IS_TRIVIALLY_ASSIGNABLE
-  static_assert(std::is_trivially_copy_assignable<T>::value ==
-                    is_trivially_copy_assignable::value,
-                "Not compliant with std::is_trivially_copy_assignable");
+  static constexpr bool compliant =
+      std::is_trivially_copy_assignable<T>::value ==
+      is_trivially_copy_assignable::value;
+  static_assert(compliant || std::is_trivially_copy_assignable<T>::value,
+                "Not compliant with std::is_trivially_copy_assignable; "
+                "Standard: false, Implementation: true");
+  static_assert(compliant || !std::is_trivially_copy_assignable<T>::value,
+                "Not compliant with std::is_trivially_copy_assignable; "
+                "Standard: true, Implementation: false");
 #endif  // ABSL_HAVE_STD_IS_TRIVIALLY_ASSIGNABLE
 };