From a0b499bc3b0dd25f7e5524aeac0d16600a1831e6 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Fri, 22 Feb 2019 01:57:09 +0200 Subject: [PATCH] Use copy_cv_ref in apply_cv_ref instead of variant_alternative_t --- include/boost/variant2/variant.hpp | 55 +++++++++++++++++++----------- 1 file changed, 35 insertions(+), 20 deletions(-) diff --git a/include/boost/variant2/variant.hpp b/include/boost/variant2/variant.hpp index 8cb7ad8..e5e9eb9 100644 --- a/include/boost/variant2/variant.hpp +++ b/include/boost/variant2/variant.hpp @@ -1585,6 +1585,40 @@ template constexpr bool operator>=( variant const & v, variant namespace detail { +template using remove_cv_ref_t = typename std::remove_cv::type>::type; + +template struct copy_cv_ref +{ + using type = T; +}; + +template struct copy_cv_ref +{ + using type = T const; +}; + +template struct copy_cv_ref +{ + using type = T volatile; +}; + +template struct copy_cv_ref +{ + using type = T const volatile; +}; + +template struct copy_cv_ref +{ + using type = typename copy_cv_ref::type&; +}; + +template struct copy_cv_ref +{ + using type = typename copy_cv_ref::type&&; +}; + +template using copy_cv_ref_t = typename copy_cv_ref::type; + template struct Qret { template using fn = decltype( std::declval()( std::declval()... ) ); @@ -1592,26 +1626,7 @@ template struct Qret template using front_if_same = mp11::mp_if, mp11::mp_front>; -template using var_alt = variant_alternative_t; - -#if BOOST_WORKAROUND( BOOST_MSVC, < 1920 ) - -template struct apply_cv_ref_impl -{ - template using _f = var_alt; - - using L = mp11::mp_iota>; - - using type = mp11::mp_transform<_f, L>; -}; - -template using apply_cv_ref = typename apply_cv_ref_impl::type; - -#else - -template using apply_cv_ref = mp11::mp_transform_q, mp11::mp_iota>>; - -#endif +template using apply_cv_ref = mp11::mp_product, mp11::mp_list>; template using Vret = front_if_same, apply_cv_ref...>>;