From 049aa40e7ec9e37ed47c4dd2452affb13cd62ebe Mon Sep 17 00:00:00 2001 From: Derek Mauro Date: Fri, 16 Jun 2023 10:41:20 -0700 Subject: Use std::is_final instead of a non-portable implementation PiperOrigin-RevId: 540928490 Change-Id: Idf022b28ce101a948be4efd5336888a66f5eacf9 --- absl/container/internal/compressed_tuple.h | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/absl/container/internal/compressed_tuple.h b/absl/container/internal/compressed_tuple.h index 5ebe1649..59e70eb2 100644 --- a/absl/container/internal/compressed_tuple.h +++ b/absl/container/internal/compressed_tuple.h @@ -64,19 +64,6 @@ struct Elem, I> template using ElemT = typename Elem::type; -// Use the __is_final intrinsic if available. Where it's not available, classes -// declared with the 'final' specifier cannot be used as CompressedTuple -// elements. -// TODO(sbenza): Replace this with std::is_final in C++14. -template -constexpr bool IsFinal() { -#if defined(__clang__) || defined(__GNUC__) - return __is_final(T); -#else - return false; -#endif -} - // We can't use EBCO on other CompressedTuples because that would mean that we // derive from multiple Storage<> instantiations with the same I parameter, // and potentially from multiple identical Storage<> instantiations. So anytime @@ -86,20 +73,15 @@ struct uses_inheritance {}; template constexpr bool ShouldUseBase() { - return std::is_class::value && std::is_empty::value && !IsFinal() && + return std::is_class::value && std::is_empty::value && + !std::is_final::value && !std::is_base_of::value; } // The storage class provides two specializations: // - For empty classes, it stores T as a base class. // - For everything else, it stores T as a member. -template ::type>()> -#else - bool UseBase = ShouldUseBase()> -#endif +template ()> struct Storage { T value; constexpr Storage() = default; -- cgit v1.2.3