From 4132ce25956a91e1224e0f205b7f8c326304a995 Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Fri, 5 Jan 2018 07:54:33 -0800 Subject: Changes imported from Abseil "staging" branch: - 0a519d9a4507158267cc515e0c7c83959d94fc78 Fix missing header include when compiling with _GLIBCXX_D... by Alex Strelnikov - d089af70781d92af9a5de2d84c417ddf2c87689a Internal change by Gennadiy Rozental - 0d3afc89d3907923ede964d58c6bcca579e8ad65 Test absl::any for exception safety. This test is tempor... by Jon Cohen - 29af424b8a3174a7b3e657e478aa30a8a425aee2 Tweak the ABSL type trait library and expand its tests. by Abseil Team - 99ab42b2ebbe466cc3730fb6b16b5fad848f95af Rollback GLIBCXX_DEBUG fix due to internal breakage. by Alex Strelnikov - 1a5bcb93ee16d4dd2170254e54c4b62b38fbf17b Internal change. by Abseil Team - 46de7d09c7d4aef5b7b5389ce9b4f96b654aac02 absl::string_view::rfind: doc fix. by Abseil Team - edda4c7ddd2d76fbb5b3fd5226b95082083c57d9 Fix string_view_test with c++17/clang/libc++ to address by Xiaoyi Zhang GitOrigin-RevId: 0a519d9a4507158267cc515e0c7c83959d94fc78 Change-Id: Ie27de1be3e79bba011f05e924d34e8fcc62d8de5 --- absl/meta/type_traits.h | 66 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 44 insertions(+), 22 deletions(-) (limited to 'absl/meta/type_traits.h') diff --git a/absl/meta/type_traits.h b/absl/meta/type_traits.h index 6f7138c..f36a59a 100644 --- a/absl/meta/type_traits.h +++ b/absl/meta/type_traits.h @@ -148,11 +148,16 @@ struct negation : std::integral_constant {}; template struct is_trivially_destructible : std::integral_constant::value> { + std::is_destructible::value> { #ifdef ABSL_HAVE_STD_IS_TRIVIALLY_DESTRUCTIBLE - static_assert(std::is_trivially_destructible::value == - is_trivially_destructible::value, - "Not compliant with std::is_trivially_destructible"); + static constexpr bool compliant = std::is_trivially_destructible::value == + is_trivially_destructible::value; + static_assert(compliant || std::is_trivially_destructible::value, + "Not compliant with std::is_trivially_destructible; " + "Standard: false, Implementation: true"); + static_assert(compliant || !std::is_trivially_destructible::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 struct is_trivially_default_constructible - : std::integral_constant::value && - is_trivially_destructible::value> { + : std::integral_constant::value && + is_trivially_destructible::value> { #ifdef ABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE - static_assert(std::is_trivially_default_constructible::value == - is_trivially_default_constructible::value, - "Not compliant with std::is_trivially_default_constructible"); + static constexpr bool compliant = + std::is_trivially_default_constructible::value == + is_trivially_default_constructible::value; + static_assert(compliant || std::is_trivially_default_constructible::value, + "Not compliant with std::is_trivially_default_constructible; " + "Standard: false, Implementation: true"); + static_assert(compliant || !std::is_trivially_default_constructible::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 struct is_trivially_copy_constructible : std::integral_constant::value && - is_trivially_destructible::value> { + std::is_copy_constructible::value && + is_trivially_destructible::value> { #ifdef ABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE - static_assert(std::is_trivially_copy_constructible::value == - is_trivially_copy_constructible::value, - "Not compliant with std::is_trivially_copy_constructible"); + static constexpr bool compliant = + std::is_trivially_copy_constructible::value == + is_trivially_copy_constructible::value; + static_assert(compliant || std::is_trivially_copy_constructible::value, + "Not compliant with std::is_trivially_copy_constructible; " + "Standard: false, Implementation: true"); + static_assert(compliant || !std::is_trivially_copy_constructible::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() = declval()` is well-formed when treated as an unevaluated // operand. `is_trivially_assignable` requires the assignment to call no // operation that is not trivial. `is_trivially_copy_assignable` is simply -// `is_trivially_assignable`. +// `is_trivially_assignable`. template struct is_trivially_copy_assignable : std::integral_constant::value> { + std::is_copy_assignable::value> { #ifdef ABSL_HAVE_STD_IS_TRIVIALLY_ASSIGNABLE - static_assert(std::is_trivially_copy_assignable::value == - is_trivially_copy_assignable::value, - "Not compliant with std::is_trivially_copy_assignable"); + static constexpr bool compliant = + std::is_trivially_copy_assignable::value == + is_trivially_copy_assignable::value; + static_assert(compliant || std::is_trivially_copy_assignable::value, + "Not compliant with std::is_trivially_copy_assignable; " + "Standard: false, Implementation: true"); + static_assert(compliant || !std::is_trivially_copy_assignable::value, + "Not compliant with std::is_trivially_copy_assignable; " + "Standard: true, Implementation: false"); #endif // ABSL_HAVE_STD_IS_TRIVIALLY_ASSIGNABLE }; -- cgit v1.2.3