From 87a2e88edbc9e9f78330714a73959f90a0f8b51e Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Thu, 21 Feb 2019 22:03:56 +0200 Subject: [PATCH] Use variant_size directly with references --- include/boost/variant2/variant.hpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/include/boost/variant2/variant.hpp b/include/boost/variant2/variant.hpp index 2d41583..a450eba 100644 --- a/include/boost/variant2/variant.hpp +++ b/include/boost/variant2/variant.hpp @@ -1520,8 +1520,6 @@ template struct Qret template using front_if_same = mp11::mp_if, mp11::mp_front>; -template using var_size = variant_size::type>; - template::type>> using apply_cv_ref_ = mp11::mp_if, T&, T>; #if BOOST_WORKAROUND( BOOST_MSVC, < 1920 ) @@ -1530,7 +1528,7 @@ template struct apply_cv_ref_impl { template using _f = apply_cv_ref_; - using L = mp11::mp_iota>; + using L = mp11::mp_iota>; using type = mp11::mp_transform<_f, L>; }; @@ -1539,7 +1537,7 @@ template using apply_cv_ref = typename apply_cv_ref_impl::type; #else -template using apply_cv_ref = mp11::mp_transform_q, mp11::mp_iota>>; +template using apply_cv_ref = mp11::mp_transform_q, mp11::mp_iota>>; #endif @@ -1570,7 +1568,7 @@ template struct visit_L1 template constexpr auto visit( F&& f, V1&& v1 ) -> detail::Vret { - return mp11::mp_with_index>( v1.index(), detail::visit_L1{ std::forward(f), std::forward(v1) } ); + return mp11::mp_with_index>( v1.index(), detail::visit_L1{ std::forward(f), std::forward(v1) } ); } #if defined(BOOST_NO_CXX14_GENERIC_LAMBDAS) || BOOST_WORKAROUND( BOOST_MSVC, < 1920 ) @@ -1612,7 +1610,7 @@ template struct visit_L2 template constexpr auto visit( F&& f, V1&& v1, V2&& v2 ) -> detail::Vret { - return mp11::mp_with_index>( v1.index(), detail::visit_L2{ std::forward(f), std::forward(v1), std::forward(v2) } ); + return mp11::mp_with_index>( v1.index(), detail::visit_L2{ std::forward(f), std::forward(v1), std::forward(v2) } ); } namespace detail @@ -1637,7 +1635,7 @@ template struct visit_L3 template constexpr auto visit( F&& f, V1&& v1, V2&& v2, V3&& v3 ) -> detail::Vret { - return mp11::mp_with_index>( v1.index(), detail::visit_L3{ std::forward(f), std::forward(v1), std::forward(v2), std::forward(v3) } ); + return mp11::mp_with_index>( v1.index(), detail::visit_L3{ std::forward(f), std::forward(v1), std::forward(v2), std::forward(v3) } ); } namespace detail @@ -1663,14 +1661,14 @@ template struct visit_L4 template constexpr auto visit( F&& f, V1&& v1, V2&& v2, V3&& v3, V4&& v4 ) -> detail::Vret { - return mp11::mp_with_index>( v1.index(), detail::visit_L4{ std::forward(f), std::forward(v1), std::forward(v2), std::forward(v3), std::forward(v4) } ); + return mp11::mp_with_index>( v1.index(), detail::visit_L4{ std::forward(f), std::forward(v1), std::forward(v2), std::forward(v3), std::forward(v4) } ); } #else template constexpr auto visit( F&& f, V1&& v1, V2&& v2, V&&... v ) -> detail::Vret { - return mp11::mp_with_index>( v1.index(), [&]( auto I ){ + return mp11::mp_with_index>( v1.index(), [&]( auto I ){ auto f2 = [&]( auto&&... a ){ return std::forward(f)( get( std::forward(v1) ), std::forward(a)... ); }; return visit( f2, std::forward(v2), std::forward(v)... );