1 | #ifndef BOOST_MP11_DETAIL_MP_MAP_FIND_HPP_INCLUDED |
2 | #define BOOST_MP11_DETAIL_MP_MAP_FIND_HPP_INCLUDED |
3 | |
4 | // Copyright 2015 Peter Dimov. |
5 | // |
6 | // Distributed under the Boost Software License, Version 1.0. |
7 | // |
8 | // See accompanying file LICENSE_1_0.txt or copy at |
9 | // http://www.boost.org/LICENSE_1_0.txt |
10 | |
11 | #include <boost/mp11/utility.hpp> |
12 | |
13 | namespace boost |
14 | { |
15 | namespace mp11 |
16 | { |
17 | |
18 | // mp_map_find |
19 | namespace detail |
20 | { |
21 | |
22 | template<class M, class K> struct mp_map_find_impl; |
23 | |
24 | template<template<class...> class M, class... T, class K> struct mp_map_find_impl<M<T...>, K> |
25 | { |
26 | using U = mp_inherit<mp_identity<T>...>; |
27 | |
28 | template<template<class...> class L, class... U> static mp_identity<L<K, U...>> f( mp_identity<L<K, U...>>* ); |
29 | static mp_identity<void> f( ... ); |
30 | |
31 | using V = decltype( f((U*)0) ); |
32 | |
33 | using type = typename V::type; |
34 | }; |
35 | |
36 | } // namespace detail |
37 | |
38 | template<class M, class K> using mp_map_find = typename detail::mp_map_find_impl<M, K>::type; |
39 | |
40 | } // namespace mp11 |
41 | } // namespace boost |
42 | |
43 | #endif // #ifndef BOOST_MP11_DETAIL_MP_MAP_FIND_HPP_INCLUDED |
44 | |