1 #ifndef BOOST_MP11_DETAIL_MP_MAP_FIND_HPP_INCLUDED
2 #define BOOST_MP11_DETAIL_MP_MAP_FIND_HPP_INCLUDED
4 // Copyright 2015 Peter Dimov.
6 // Distributed under the Boost Software License, Version 1.0.
8 // See accompanying file LICENSE_1_0.txt or copy at
9 // http://www.boost.org/LICENSE_1_0.txt
11 #include <boost/mp11/utility.hpp>
12 #include <boost/mp11/detail/config.hpp>
14 #if BOOST_MP11_WORKAROUND( BOOST_MP11_MSVC, < 1930 )
16 // not exactly good practice, but...
19 template<class... _Types> class tuple;
33 #if !BOOST_MP11_WORKAROUND( BOOST_MP11_MSVC, < 1930 )
35 template<class T> using mpmf_wrap = mp_identity<T>;
36 template<class T> using mpmf_unwrap = typename T::type;
40 template<class... T> struct mpmf_tuple {};
42 template<class T> struct mpmf_wrap_impl
44 using type = mp_identity<T>;
47 template<class... T> struct mpmf_wrap_impl< std::tuple<T...> >
49 using type = mp_identity< mpmf_tuple<T...> >;
52 template<class T> using mpmf_wrap = typename mpmf_wrap_impl<T>::type;
54 template<class T> struct mpmf_unwrap_impl
56 using type = typename T::type;
59 template<class... T> struct mpmf_unwrap_impl< mp_identity< mpmf_tuple<T...> > >
61 using type = std::tuple<T...>;
64 template<class T> using mpmf_unwrap = typename mpmf_unwrap_impl<T>::type;
66 #endif // #if !BOOST_MP11_WORKAROUND( BOOST_MP11_MSVC, < 1930 )
68 template<class M, class K> struct mp_map_find_impl;
70 template<template<class...> class M, class... T, class K> struct mp_map_find_impl<M<T...>, K>
72 using U = mp_inherit<mpmf_wrap<T>...>;
74 template<template<class...> class L, class... U> static mp_identity<L<K, U...>> f( mp_identity<L<K, U...>>* );
75 static mp_identity<void> f( ... );
77 using type = mpmf_unwrap< decltype( f((U*)0) ) >;
82 template<class M, class K> using mp_map_find = typename detail::mp_map_find_impl<M, K>::type;
87 #endif // #ifndef BOOST_MP11_DETAIL_MP_MAP_FIND_HPP_INCLUDED