diff --git a/absl/types/internal/variant.h b/absl/types/internal/variant.h index 9adea563..c82ded44 100644 --- a/absl/types/internal/variant.h +++ b/absl/types/internal/variant.h @@ -449,7 +449,7 @@ struct FlattenIndices; template struct FlattenIndices { - template + template static constexpr std::size_t Run(std::size_t head, SizeType... tail) { return head + HeadSize * FlattenIndices::Run(tail...); } @@ -498,8 +498,8 @@ struct VisitIndicesVariadicImpl, EndIndices...> { }; template - static VisitIndicesResultT Run( - Op&& op, SizeType... i) { + static VisitIndicesResultT Run(Op&& op, + SizeType... i) { return VisitIndicesSwitch::value>::Run( FlattenedOp{absl::forward(op)}, FlattenIndices<(EndIndices + std::size_t{1})...>::Run( @@ -683,13 +683,13 @@ struct VariantCoreAccess { variant_internal::IndexOfConstructedType; void operator()(SizeT /*old_i*/ - ) const { + ) const { Access(*left) = absl::forward(other); } template void operator()(SizeT /*old_i*/ - ) const { + ) const { using New = typename absl::variant_alternative::type; if (std::is_nothrow_constructible::value || @@ -868,18 +868,6 @@ struct IsNeitherSelfNorInPlace> : std::false_type {}; template struct IsNeitherSelfNorInPlace> : std::false_type {}; -template -struct ConversionIsPossibleImpl : std::false_type {}; - -template -struct ConversionIsPossibleImpl< - Variant, T, - void_t::Run(std::declval(), {}))>> - : std::true_type {}; - -template -struct ConversionIsPossible : ConversionIsPossibleImpl::type {}; - template struct IndexOfConstructedType< Variant, T, @@ -1151,16 +1139,16 @@ struct VariantHelper> { // Type metafunction which returns the element type selected if // OverloadSet::Overload() is well-formed when called with argument type U. template - using BestMatch = decltype( - variant_internal::OverloadSet::Overload(std::declval())); + using BestMatch = decltype(variant_internal::OverloadSet::Overload( + std::declval())); // Type metafunction which returns true if OverloadSet::Overload() is // well-formed when called with argument type U. // CanAccept can't be just an alias because there is a MSVC bug on parameter // pack expansion involving decltype. template - struct CanAccept : - std::integral_constant>::value> {}; + struct CanAccept + : std::integral_constant>::value> {}; // Type metafunction which returns true if Other is an instantiation of // variant, and variants's converting constructor from Other will be @@ -1183,8 +1171,8 @@ struct TrivialMoveOnly { // A union's defaulted copy/move constructor is deleted if any variant member's // copy/move constructor is nontrivial. template -struct IsTriviallyMoveConstructible: - std::is_move_constructible> {}; +struct IsTriviallyMoveConstructible + : std::is_move_constructible> {}; // To guarantee triviality of all special-member functions that can be trivial, // we use a chain of conditional bases for each one. @@ -1419,14 +1407,14 @@ class VariantMoveAssignBaseNontrivial : protected VariantCopyBase { VariantMoveAssignBaseNontrivial& operator=( VariantMoveAssignBaseNontrivial const&) = default; - VariantMoveAssignBaseNontrivial& - operator=(VariantMoveAssignBaseNontrivial&& other) noexcept( - absl::conjunction..., - std::is_nothrow_move_assignable...>::value) { - VisitIndices::Run( - VariantCoreAccess::MakeMoveAssignVisitor(this, &other), other.index_); - return *this; - } + VariantMoveAssignBaseNontrivial& + operator=(VariantMoveAssignBaseNontrivial&& other) noexcept( + absl::conjunction..., + std::is_nothrow_move_assignable...>::value) { + VisitIndices::Run( + VariantCoreAccess::MakeMoveAssignVisitor(this, &other), other.index_); + return *this; + } protected: using Base::index_; @@ -1450,12 +1438,12 @@ class VariantCopyAssignBaseNontrivial : protected VariantMoveAssignBase { VariantCopyAssignBaseNontrivial& operator=( VariantCopyAssignBaseNontrivial&&) = default; - VariantCopyAssignBaseNontrivial& operator=( - const VariantCopyAssignBaseNontrivial& other) { - VisitIndices::Run( - VariantCoreAccess::MakeCopyAssignVisitor(this, other), other.index_); - return *this; - } + VariantCopyAssignBaseNontrivial& operator=( + const VariantCopyAssignBaseNontrivial& other) { + VisitIndices::Run( + VariantCoreAccess::MakeCopyAssignVisitor(this, other), other.index_); + return *this; + } protected: using Base::index_;