@@ -657,6 +657,10 @@ private:
657
657
658
658
} // namespace __visitation
659
659
660
+ // Adding semi-colons in macro expansions helps clang-format to do a better job.
661
+ // This macro is used to avoid compilation errors due to "stray" semi-colons.
662
+ # define _LIBCPP_EAT_SEMICOLON static_assert (true , " " )
663
+
660
664
template <size_t _Index, class _Tp>
661
665
struct _LIBCPP_TEMPLATE_VIS __alt {
662
666
using __value_type = _Tp;
@@ -691,11 +695,10 @@ union _LIBCPP_TEMPLATE_VIS __union<_DestructibleTrait, _Index> {};
691
695
__union (const __union&) = default ; \
692
696
__union (__union&&) = default ; \
693
697
\
694
- destructor \
698
+ destructor; \
695
699
\
696
- __union& \
697
- operator =(const __union&) = default ; \
698
- __union& operator =(__union&&) = default ; \
700
+ __union& operator =(const __union&) = default ; \
701
+ __union& operator =(__union&&) = default ; \
699
702
\
700
703
private: \
701
704
char __dummy; \
@@ -705,9 +708,10 @@ union _LIBCPP_TEMPLATE_VIS __union<_DestructibleTrait, _Index> {};
705
708
friend struct __access ::__union; \
706
709
}
707
710
708
- _LIBCPP_VARIANT_UNION (_Trait::_TriviallyAvailable, ~__union () = default ;);
709
- _LIBCPP_VARIANT_UNION (_Trait::_Available, ~__union (){});
710
- _LIBCPP_VARIANT_UNION (_Trait::_Unavailable, ~__union () = delete ;);
711
+ _LIBCPP_VARIANT_UNION (_Trait::_TriviallyAvailable, ~__union () = default );
712
+ _LIBCPP_VARIANT_UNION (
713
+ _Trait::_Available, _LIBCPP_HIDE_FROM_ABI ~__union () {} _LIBCPP_EAT_SEMICOLON);
714
+ _LIBCPP_VARIANT_UNION (_Trait::_Unavailable, ~__union () = delete );
711
715
712
716
# undef _LIBCPP_VARIANT_UNION
713
717
@@ -761,23 +765,27 @@ class _LIBCPP_TEMPLATE_VIS __dtor;
761
765
using __base_type::__base_type; \
762
766
using __base_type::operator =; \
763
767
\
764
- __dtor (const __dtor&) = default ; \
765
- __dtor (__dtor&&) = default ; \
766
- destructor __dtor& operator =(const __dtor&) = default ; \
767
- __dtor& operator =(__dtor&&) = default ; \
768
+ __dtor (const __dtor&) = default ; \
769
+ __dtor (__dtor&&) = default ; \
770
+ __dtor& operator =(const __dtor&) = default ; \
771
+ __dtor& operator =(__dtor&&) = default ; \
772
+ destructor; \
768
773
\
769
774
protected: \
770
- inline _LIBCPP_HIDE_FROM_ABI destroy \
775
+ inline _LIBCPP_HIDE_FROM_ABI destroy; \
771
776
}
772
777
773
778
_LIBCPP_VARIANT_DESTRUCTOR (
774
- _Trait::_TriviallyAvailable, ~__dtor () = default ;
775
- , void __destroy () noexcept { this ->__index = __variant_npos<__index_t >; });
779
+ _Trait::_TriviallyAvailable,
780
+ ~__dtor () = default , //
781
+ _LIBCPP_HIDE_FROM_ABI void __destroy () noexcept {
782
+ this ->__index = __variant_npos<__index_t >;
783
+ } _LIBCPP_EAT_SEMICOLON);
776
784
777
785
_LIBCPP_VARIANT_DESTRUCTOR (
778
786
_Trait::_Available,
779
- ~__dtor () { __destroy (); },
780
- void __destroy () noexcept {
787
+ _LIBCPP_HIDE_FROM_ABI ~__dtor () { __destroy (); } _LIBCPP_EAT_SEMICOLON ,
788
+ _LIBCPP_HIDE_FROM_ABI void __destroy () noexcept {
781
789
if (!this ->valueless_by_exception ()) {
782
790
__visitation::__base::__visit_alt (
783
791
[](auto & __alt) noexcept {
@@ -787,9 +795,9 @@ _LIBCPP_VARIANT_DESTRUCTOR(
787
795
*this );
788
796
}
789
797
this ->__index = __variant_npos<__index_t >;
790
- });
798
+ } _LIBCPP_EAT_SEMICOLON );
791
799
792
- _LIBCPP_VARIANT_DESTRUCTOR (_Trait::_Unavailable, ~__dtor () = delete ; , void __destroy () noexcept = delete; );
800
+ _LIBCPP_VARIANT_DESTRUCTOR (_Trait::_Unavailable, ~__dtor () = delete , void __destroy () noexcept = delete);
793
801
794
802
# undef _LIBCPP_VARIANT_DESTRUCTOR
795
803
@@ -839,20 +847,24 @@ class _LIBCPP_TEMPLATE_VIS __move_constructor;
839
847
using __base_type::operator =; \
840
848
\
841
849
__move_constructor (const __move_constructor&) = default ; \
842
- move_constructor ~__move_constructor () = default ; \
850
+ ~__move_constructor () = default ; \
843
851
__move_constructor& operator =(const __move_constructor&) = default ; \
844
852
__move_constructor& operator =(__move_constructor&&) = default ; \
853
+ move_constructor; \
845
854
}
846
855
847
856
_LIBCPP_VARIANT_MOVE_CONSTRUCTOR (_Trait::_TriviallyAvailable,
848
- __move_constructor (__move_constructor&& __that) = default; );
857
+ __move_constructor (__move_constructor&& __that) = default);
849
858
850
859
_LIBCPP_VARIANT_MOVE_CONSTRUCTOR (
851
860
_Trait::_Available,
852
- __move_constructor (__move_constructor&& __that) noexcept (__all<is_nothrow_move_constructible_v<_Types>...>::value)
853
- : __move_constructor(__valueless_t {}) { this ->__generic_construct (*this , std::move (__that)); });
861
+ _LIBCPP_HIDE_FROM_ABI __move_constructor (__move_constructor&& __that) noexcept (
862
+ __all<is_nothrow_move_constructible_v<_Types>...>::value)
863
+ : __move_constructor(__valueless_t {}) {
864
+ this ->__generic_construct (*this , std::move (__that));
865
+ } _LIBCPP_EAT_SEMICOLON);
854
866
855
- _LIBCPP_VARIANT_MOVE_CONSTRUCTOR (_Trait::_Unavailable, __move_constructor(__move_constructor&&) = delete; );
867
+ _LIBCPP_VARIANT_MOVE_CONSTRUCTOR (_Trait::_Unavailable, __move_constructor(__move_constructor&&) = delete);
856
868
857
869
# undef _LIBCPP_VARIANT_MOVE_CONSTRUCTOR
858
870
@@ -869,20 +881,21 @@ class _LIBCPP_TEMPLATE_VIS __copy_constructor;
869
881
using __base_type::__base_type; \
870
882
using __base_type::operator =; \
871
883
\
872
- copy_constructor __copy_constructor (__copy_constructor&&) = default; \
873
- ~__copy_constructor () = default ; \
874
- __copy_constructor& operator =(const __copy_constructor&) = default ; \
875
- __copy_constructor& operator =(__copy_constructor&&) = default ; \
876
- }
884
+ __copy_constructor (__copy_constructor&&) = default ; \
885
+ ~__copy_constructor () = default ; \
886
+ __copy_constructor& operator =(const __copy_constructor&) = default ; \
887
+ __copy_constructor& operator =(__copy_constructor&&) = default ; \
888
+ copy_constructor; \
889
+ } // namespace __variant_detail
877
890
878
891
_LIBCPP_VARIANT_COPY_CONSTRUCTOR (_Trait::_TriviallyAvailable,
879
- __copy_constructor (const __copy_constructor& __that) = default; );
892
+ __copy_constructor (const __copy_constructor& __that) = default);
880
893
881
894
_LIBCPP_VARIANT_COPY_CONSTRUCTOR (
882
- _Trait::_Available, __copy_constructor(const __copy_constructor& __that)
883
- : __copy_constructor(__valueless_t {}) { this ->__generic_construct (*this , __that); });
895
+ _Trait::_Available, _LIBCPP_HIDE_FROM_ABI __copy_constructor (const __copy_constructor& __that)
896
+ : __copy_constructor(__valueless_t {}) { this ->__generic_construct (*this , __that); } _LIBCPP_EAT_SEMICOLON );
884
897
885
- _LIBCPP_VARIANT_COPY_CONSTRUCTOR (_Trait::_Unavailable, __copy_constructor(const __copy_constructor&) = delete ; );
898
+ _LIBCPP_VARIANT_COPY_CONSTRUCTOR (_Trait::_Unavailable, __copy_constructor(const __copy_constructor&) = delete);
886
899
887
900
# undef _LIBCPP_VARIANT_COPY_CONSTRUCTOR
888
901
@@ -955,22 +968,22 @@ class _LIBCPP_TEMPLATE_VIS __move_assignment;
955
968
__move_assignment (__move_assignment&&) = default ; \
956
969
~__move_assignment () = default ; \
957
970
__move_assignment& operator =(const __move_assignment&) = default ; \
958
- move_assignment \
971
+ move_assignment; \
959
972
}
960
973
961
974
_LIBCPP_VARIANT_MOVE_ASSIGNMENT (_Trait::_TriviallyAvailable,
962
- __move_assignment& operator =(__move_assignment&& __that) = default; );
975
+ __move_assignment& operator =(__move_assignment&& __that) = default);
963
976
964
977
_LIBCPP_VARIANT_MOVE_ASSIGNMENT (
965
978
_Trait::_Available,
966
- __move_assignment&
979
+ _LIBCPP_HIDE_FROM_ABI __move_assignment&
967
980
operator =(__move_assignment&& __that) noexcept (
968
981
__all<(is_nothrow_move_constructible_v<_Types> && is_nothrow_move_assignable_v<_Types>)...>::value) {
969
982
this ->__generic_assign (std::move (__that));
970
983
return *this ;
971
- });
984
+ } _LIBCPP_EAT_SEMICOLON );
972
985
973
- _LIBCPP_VARIANT_MOVE_ASSIGNMENT (_Trait::_Unavailable, __move_assignment& operator =(__move_assignment&&) = delete ; );
986
+ _LIBCPP_VARIANT_MOVE_ASSIGNMENT (_Trait::_Unavailable, __move_assignment& operator =(__move_assignment&&) = delete);
974
987
975
988
# undef _LIBCPP_VARIANT_MOVE_ASSIGNMENT
976
989
@@ -987,22 +1000,23 @@ class _LIBCPP_TEMPLATE_VIS __copy_assignment;
987
1000
using __base_type::__base_type; \
988
1001
using __base_type::operator =; \
989
1002
\
990
- __copy_assignment (const __copy_assignment&) = default ; \
991
- __copy_assignment (__copy_assignment&&) = default ; \
992
- ~__copy_assignment () = default ; \
993
- copy_assignment __copy_assignment& operator =(__copy_assignment&&) = default ; \
1003
+ __copy_assignment (const __copy_assignment&) = default ; \
1004
+ __copy_assignment (__copy_assignment&&) = default ; \
1005
+ ~__copy_assignment () = default ; \
1006
+ __copy_assignment& operator =(__copy_assignment&&) = default ; \
1007
+ copy_assignment; \
994
1008
}
995
1009
996
1010
_LIBCPP_VARIANT_COPY_ASSIGNMENT (_Trait::_TriviallyAvailable,
997
- __copy_assignment& operator =(const __copy_assignment& __that) = default; );
1011
+ __copy_assignment& operator =(const __copy_assignment& __that) = default);
998
1012
999
1013
_LIBCPP_VARIANT_COPY_ASSIGNMENT (
1000
- _Trait::_Available, __copy_assignment& operator =(const __copy_assignment& __that) {
1014
+ _Trait::_Available, _LIBCPP_HIDE_FROM_ABI __copy_assignment& operator =(const __copy_assignment& __that) {
1001
1015
this ->__generic_assign (__that);
1002
1016
return *this ;
1003
- });
1017
+ } _LIBCPP_EAT_SEMICOLON );
1004
1018
1005
- _LIBCPP_VARIANT_COPY_ASSIGNMENT (_Trait::_Unavailable, __copy_assignment& operator =(const __copy_assignment&) = delete ; );
1019
+ _LIBCPP_VARIANT_COPY_ASSIGNMENT (_Trait::_Unavailable, __copy_assignment& operator =(const __copy_assignment&) = delete);
1006
1020
1007
1021
# undef _LIBCPP_VARIANT_COPY_ASSIGNMENT
1008
1022
0 commit comments