mirror of
https://github.com/boostorg/mp11.git
synced 2025-08-03 22:44:27 +02:00
Work around std::tuple MSVC issue with mp_map_find (fixes #52)
This commit is contained in:
@@ -9,6 +9,17 @@
|
|||||||
// http://www.boost.org/LICENSE_1_0.txt
|
// http://www.boost.org/LICENSE_1_0.txt
|
||||||
|
|
||||||
#include <boost/mp11/utility.hpp>
|
#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
|
namespace boost
|
||||||
{
|
{
|
||||||
@@ -19,18 +30,51 @@ namespace mp11
|
|||||||
namespace detail
|
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<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>
|
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...>>* );
|
template<template<class...> class L, class... U> static mp_identity<L<K, U...>> f( mp_identity<L<K, U...>>* );
|
||||||
static mp_identity<void> f( ... );
|
static mp_identity<void> f( ... );
|
||||||
|
|
||||||
using V = decltype( f((U*)0) );
|
using type = mpmf_unwrap< decltype( f((U*)0) ) >;
|
||||||
|
|
||||||
using type = typename V::type;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
Reference in New Issue
Block a user