diff --git a/absl/container/internal/compressed_tuple.h b/absl/container/internal/compressed_tuple.h index 02bfd03..d25d96d 100644 --- a/absl/container/internal/compressed_tuple.h +++ b/absl/container/internal/compressed_tuple.h @@ -32,7 +32,6 @@ #ifndef ABSL_CONTAINER_INTERNAL_COMPRESSED_TUPLE_H_ #define ABSL_CONTAINER_INTERNAL_COMPRESSED_TUPLE_H_ -#include #include #include #include @@ -77,134 +76,61 @@ constexpr bool IsFinal() { #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 -// we use type inheritance rather than encapsulation, we mark -// CompressedTupleImpl, to make this easy to detect. -struct uses_inheritance {}; - template constexpr bool ShouldUseBase() { - return std::is_class::value && std::is_empty::value && !IsFinal() && - !std::is_base_of::value; + return std::is_class::value && std::is_empty::value && !IsFinal(); } // 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 { + using T = ElemT; T value; constexpr Storage() = default; - template - explicit constexpr Storage(absl::in_place_t, V&& v) - : value(absl::forward(v)) {} + explicit constexpr Storage(T&& v) : value(absl::forward(v)) {} constexpr const T& get() const& { return value; } T& get() & { return value; } constexpr const T&& get() const&& { return absl::move(*this).value; } T&& get() && { return std::move(*this).value; } }; -template -struct ABSL_INTERNAL_COMPRESSED_TUPLE_DECLSPEC Storage : T { +template +struct ABSL_INTERNAL_COMPRESSED_TUPLE_DECLSPEC Storage + : ElemT { + using T = internal_compressed_tuple::ElemT; constexpr Storage() = default; - - template - explicit constexpr Storage(absl::in_place_t, V&& v) - : T(absl::forward(v)) {} - + explicit constexpr Storage(T&& v) : T(absl::forward(v)) {} constexpr const T& get() const& { return *this; } T& get() & { return *this; } constexpr const T&& get() const&& { return absl::move(*this); } T&& get() && { return std::move(*this); } }; -template +template struct ABSL_INTERNAL_COMPRESSED_TUPLE_DECLSPEC CompressedTupleImpl; -template -struct ABSL_INTERNAL_COMPRESSED_TUPLE_DECLSPEC CompressedTupleImpl< - CompressedTuple, absl::index_sequence, ShouldAnyUseBase> +template +struct ABSL_INTERNAL_COMPRESSED_TUPLE_DECLSPEC + CompressedTupleImpl, absl::index_sequence> // We use the dummy identity function through std::integral_constant to // convince MSVC of accepting and expanding I in that context. Without it // you would get: // error C3548: 'I': parameter pack cannot be used in this context - : uses_inheritance, - Storage::value>... { + : Storage, + std::integral_constant::value>... { constexpr CompressedTupleImpl() = default; - template - explicit constexpr CompressedTupleImpl(absl::in_place_t, Vs&&... args) - : Storage(absl::in_place, absl::forward(args))... {} - friend CompressedTuple; + explicit constexpr CompressedTupleImpl(Ts&&... args) + : Storage, I>(absl::forward(args))... {} }; -template -struct ABSL_INTERNAL_COMPRESSED_TUPLE_DECLSPEC CompressedTupleImpl< - CompressedTuple, absl::index_sequence, false> - // We use the dummy identity function as above... - : Storage::value, false>... { - constexpr CompressedTupleImpl() = default; - template - explicit constexpr CompressedTupleImpl(absl::in_place_t, Vs&&... args) - : Storage(absl::in_place, absl::forward(args))... {} - friend CompressedTuple; -}; - -std::false_type Or(std::initializer_list); -std::true_type Or(std::initializer_list); - -// MSVC requires this to be done separately rather than within the declaration -// of CompressedTuple below. -template -constexpr bool ShouldAnyUseBase() { - return decltype( - Or({std::integral_constant()>()...})){}; -} - -template -using TupleElementMoveConstructible = - typename std::conditional::value, - std::is_convertible, - std::is_constructible>::type; - -template -struct TupleMoveConstructible : std::false_type {}; - -template -struct TupleMoveConstructible, Vs...> - : std::integral_constant< - bool, absl::conjunction< - TupleElementMoveConstructible...>::value> {}; - -template -struct compressed_tuple_size; - -template -struct compressed_tuple_size> - : public std::integral_constant {}; - -template -struct TupleItemsMoveConstructible - : std::integral_constant< - bool, TupleMoveConstructible::value == - sizeof...(Vs), - T, Vs...>::value> {}; - } // namespace internal_compressed_tuple // Helper class to perform the Empty Base Class Optimization. // Ts can contain classes and non-classes, empty or not. For the ones that // are empty classes, we perform the CompressedTuple. If all types in Ts are -// empty classes, then CompressedTuple is itself an empty class. (This -// does not apply when one or more of those empty classes is itself an empty -// CompressedTuple.) +// empty classes, then CompressedTuple is itself an empty class. // // To access the members, use member .get() function. // @@ -220,59 +146,36 @@ struct TupleItemsMoveConstructible template class ABSL_INTERNAL_COMPRESSED_TUPLE_DECLSPEC CompressedTuple : private internal_compressed_tuple::CompressedTupleImpl< - CompressedTuple, absl::index_sequence_for, - internal_compressed_tuple::ShouldAnyUseBase()> { + CompressedTuple, absl::index_sequence_for> { private: template using ElemT = internal_compressed_tuple::ElemT; - template - using StorageT = internal_compressed_tuple::Storage, I>; - public: - // There seems to be a bug in MSVC dealing in which using '=default' here will - // cause the compiler to ignore the body of other constructors. The work- - // around is to explicitly implement the default constructor. -#if defined(_MSC_VER) - constexpr CompressedTuple() : CompressedTuple::CompressedTupleImpl() {} -#else constexpr CompressedTuple() = default; -#endif - explicit constexpr CompressedTuple(const Ts&... base) - : CompressedTuple::CompressedTupleImpl(absl::in_place, base...) {} - - template )>>, - internal_compressed_tuple::TupleItemsMoveConstructible< - CompressedTuple, First, Vs...>>::value, - bool> = true> - explicit constexpr CompressedTuple(First&& first, Vs&&... base) - : CompressedTuple::CompressedTupleImpl(absl::in_place, - absl::forward(first), - absl::forward(base)...) {} + explicit constexpr CompressedTuple(Ts... base) + : CompressedTuple::CompressedTupleImpl(absl::forward(base)...) {} template ElemT& get() & { - return StorageT::get(); + return internal_compressed_tuple::Storage::get(); } template constexpr const ElemT& get() const& { - return StorageT::get(); + return internal_compressed_tuple::Storage::get(); } template ElemT&& get() && { - return std::move(*this).StorageT::get(); + return std::move(*this) + .internal_compressed_tuple::template Storage::get(); } template constexpr const ElemT&& get() const&& { - return absl::move(*this).StorageT::get(); + return absl::move(*this) + .internal_compressed_tuple::template Storage::get(); } }; diff --git a/absl/time/internal/cctz/BUILD.bazel b/absl/time/internal/cctz/BUILD.bazel index 45a9529..57c954e 100644 --- a/absl/time/internal/cctz/BUILD.bazel +++ b/absl/time/internal/cctz/BUILD.bazel @@ -74,15 +74,6 @@ cc_library( "include/cctz/time_zone.h", "include/cctz/zone_info_source.h", ], - linkopts = select({ - ":osx": [ - "-framework Foundation", - ], - ":ios": [ - "-framework Foundation", - ], - "//conditions:default": [], - }), visibility = ["//visibility:public"], deps = [ ":civil_time",