From 4515938bbd4e32de758adcbe52157540559c8347 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 25 Jul 2020 01:56:00 +0300 Subject: [PATCH] Work around std::tuple MSVC issue with mp_map_find (fixes #52) --- include/boost/mp11/detail/mp_map_find.hpp | 52 +++++++++++++++++++++-- 1 file changed, 48 insertions(+), 4 deletions(-) diff --git a/include/boost/mp11/detail/mp_map_find.hpp b/include/boost/mp11/detail/mp_map_find.hpp index ec0fabd..5ba58a4 100644 --- a/include/boost/mp11/detail/mp_map_find.hpp +++ b/include/boost/mp11/detail/mp_map_find.hpp @@ -9,6 +9,17 @@ // http://www.boost.org/LICENSE_1_0.txt #include +#include + +#if BOOST_MP11_WORKAROUND( BOOST_MP11_MSVC, < 1930 ) + +// not exactly good practice, but... +namespace std +{ + template class tuple; +} + +#endif namespace boost { @@ -19,18 +30,51 @@ namespace mp11 namespace detail { +#if !BOOST_MP11_WORKAROUND( BOOST_MP11_MSVC, < 1930 ) + +template using mpmf_wrap = mp_identity; +template using mpmf_unwrap = typename T::type; + +#else + +template struct mpmf_tuple {}; + +template struct mpmf_wrap_impl +{ + using type = mp_identity; +}; + +template struct mpmf_wrap_impl< std::tuple > +{ + using type = mp_identity< mpmf_tuple >; +}; + +template using mpmf_wrap = typename mpmf_wrap_impl::type; + +template struct mpmf_unwrap_impl +{ + using type = typename T::type; +}; + +template struct mpmf_unwrap_impl< mp_identity< mpmf_tuple > > +{ + using type = std::tuple; +}; + +template using mpmf_unwrap = typename mpmf_unwrap_impl::type; + +#endif // #if !BOOST_MP11_WORKAROUND( BOOST_MP11_MSVC, < 1930 ) + template struct mp_map_find_impl; template class M, class... T, class K> struct mp_map_find_impl, K> { - using U = mp_inherit...>; + using U = mp_inherit...>; template class L, class... U> static mp_identity> f( mp_identity>* ); static mp_identity f( ... ); - using V = decltype( f((U*)0) ); - - using type = typename V::type; + using type = mpmf_unwrap< decltype( f((U*)0) ) >; }; } // namespace detail