1
0
forked from boostorg/mp11

Work around std::tuple MSVC issue with mp_map_find (fixes #52)

This commit is contained in:
Peter Dimov
2020-07-25 01:56:00 +03:00
parent 637c586e02
commit 4515938bbd

View File

@@ -9,6 +9,17 @@
// http://www.boost.org/LICENSE_1_0.txt
#include <boost/mp11/utility.hpp>
#include <boost/mp11/detail/config.hpp>
#if BOOST_MP11_WORKAROUND( BOOST_MP11_MSVC, < 1930 )
// not exactly good practice, but...
namespace std
{
template<class... _Types> class tuple;
}
#endif
namespace boost
{
@@ -19,18 +30,51 @@ namespace mp11
namespace detail
{
#if !BOOST_MP11_WORKAROUND( BOOST_MP11_MSVC, < 1930 )
template<class T> using mpmf_wrap = mp_identity<T>;
template<class T> using mpmf_unwrap = typename T::type;
#else
template<class... T> struct mpmf_tuple {};
template<class T> struct mpmf_wrap_impl
{
using type = mp_identity<T>;
};
template<class... T> struct mpmf_wrap_impl< std::tuple<T...> >
{
using type = mp_identity< mpmf_tuple<T...> >;
};
template<class T> using mpmf_wrap = typename mpmf_wrap_impl<T>::type;
template<class T> struct mpmf_unwrap_impl
{
using type = typename T::type;
};
template<class... T> struct mpmf_unwrap_impl< mp_identity< mpmf_tuple<T...> > >
{
using type = std::tuple<T...>;
};
template<class T> using mpmf_unwrap = typename mpmf_unwrap_impl<T>::type;
#endif // #if !BOOST_MP11_WORKAROUND( BOOST_MP11_MSVC, < 1930 )
template<class M, class K> struct mp_map_find_impl;
template<template<class...> class M, class... T, class K> struct mp_map_find_impl<M<T...>, K>
{
using U = mp_inherit<mp_identity<T>...>;
using U = mp_inherit<mpmf_wrap<T>...>;
template<template<class...> class L, class... U> static mp_identity<L<K, U...>> f( mp_identity<L<K, U...>>* );
static mp_identity<void> f( ... );
using V = decltype( f((U*)0) );
using type = typename V::type;
using type = mpmf_unwrap< decltype( f((U*)0) ) >;
};
} // namespace detail