From 17bc06b0904716c6f0220eaa2f2d368637ed6887 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Wed, 22 Jan 2020 17:38:45 +0200 Subject: [PATCH] Apply msvc-14.0 workarounds --- include/boost/variant2/variant.hpp | 44 ++++++++++++++++++++++++++++++ test/Jamfile | 18 ++++++------ 2 files changed, 53 insertions(+), 9 deletions(-) diff --git a/include/boost/variant2/variant.hpp b/include/boost/variant2/variant.hpp index d930e58..61e113e 100644 --- a/include/boost/variant2/variant.hpp +++ b/include/boost/variant2/variant.hpp @@ -1257,9 +1257,27 @@ public: { } +#if !BOOST_WORKAROUND( BOOST_MSVC, < 1910 ) + variant( variant const& ) = default; variant( variant && ) = default; +#else + +private: + + variant( variant const volatile& ) = delete; + +public: + + template::value >::type> + constexpr variant( variant const& r ) noexcept( std::is_nothrow_copy_constructible::value ): variant_base( static_cast( r ) ) {} + + template::value >::type> + constexpr variant( variant && r ) noexcept( std::is_nothrow_move_constructible::value ): variant_base( static_cast( r ) ) {} + +#endif + template::type, class E1 = typename std::enable_if< !std::is_same::value && !detail::is_in_place_index::value && !detail::is_in_place_type::value >::type, @@ -1294,9 +1312,35 @@ public: // assignment +#if !BOOST_WORKAROUND( BOOST_MSVC, < 1910 ) + variant& operator=( variant const& ) = default; variant& operator=( variant && ) = default; +#else + +private: + + variant& operator=( variant const volatile& ) = delete; + +public: + + template::value >::type> + variant& operator=( variant const& r ) noexcept( std::is_nothrow_copy_assignable::value ) + { + static_cast< variant_base& >( *this ) = static_cast< variant_base const& >( r ); + return *this; + } + + template::value >::type> + variant& operator=( variant && r ) noexcept( std::is_nothrow_move_assignable::value ) + { + static_cast< variant_base& >( *this ) = static_cast< variant_base && >( r ); + return *this; + } + +#endif + template::type, variant>::value>::type, class V = detail::resolve_overload_type, diff --git a/test/Jamfile b/test/Jamfile index 73b2498..d28c1e5 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -29,16 +29,16 @@ run variant_size.cpp ; run variant_alternative.cpp ; run variant_holds_alternative.cpp ; -compile variant_holds_alternative_cx.cpp ; +compile variant_holds_alternative_cx.cpp : msvc-14.0:no ; run variant_get_by_index.cpp ; -compile variant_get_by_index_cx.cpp ; +compile variant_get_by_index_cx.cpp : msvc-14.0:no ; run variant_get_by_type.cpp ; -compile variant_get_by_type_cx.cpp ; +compile variant_get_by_type_cx.cpp : msvc-14.0:no ; run variant_default_construct.cpp ; -compile variant_default_construct_cx.cpp ; +compile variant_default_construct_cx.cpp : msvc-14.0:no ; run variant_copy_construct.cpp ; compile variant_copy_construct_cx.cpp : msvc-14.0:no ; @@ -47,13 +47,13 @@ run variant_move_construct.cpp ; compile variant_move_construct_cx.cpp : [ requires cxx14_constexpr ] ; run variant_value_construct.cpp ; -compile variant_value_construct_cx.cpp ; +compile variant_value_construct_cx.cpp : msvc-14.0:no ; run variant_in_place_index_construct.cpp ; -compile variant_in_place_index_construct_cx.cpp ; +compile variant_in_place_index_construct_cx.cpp : msvc-14.0:no ; run variant_in_place_type_construct.cpp ; -compile variant_in_place_type_construct_cx.cpp ; +compile variant_in_place_type_construct_cx.cpp : msvc-14.0:no ; run variant_copy_assign.cpp ; compile variant_copy_assign_cx.cpp : [ requires cxx14_constexpr ] ; @@ -99,10 +99,10 @@ local NX = ; run variant_get_by_index.cpp throw_exception.cpp : : : $(NX) : variant_get_by_index_nx ; -compile variant_get_by_index_cx.cpp : $(NX) : variant_get_by_index_cx_nx ; +compile variant_get_by_index_cx.cpp : $(NX) msvc-14.0:no : variant_get_by_index_cx_nx ; run variant_get_by_type.cpp throw_exception.cpp : : : $(NX) : variant_get_by_type_nx ; -compile variant_get_by_type_cx.cpp : $(NX) : variant_get_by_type_cx_nx ; +compile variant_get_by_type_cx.cpp : $(NX) msvc-14.0:no : variant_get_by_type_cx_nx ; run variant_subset.cpp throw_exception.cpp : : : $(NX) : variant_subset_nx ;