]>
Commit | Line | Data |
---|---|---|
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 | #include <boost/mp11/detail/config.hpp> | |
13 | ||
14 | #if BOOST_MP11_WORKAROUND( BOOST_MP11_MSVC, < 1930 ) | |
15 | ||
16 | // not exactly good practice, but... | |
17 | namespace std | |
18 | { | |
19 | template<class... _Types> class tuple; | |
20 | } | |
21 | ||
22 | #endif | |
23 | ||
24 | namespace boost | |
25 | { | |
26 | namespace mp11 | |
27 | { | |
28 | ||
29 | // mp_map_find | |
30 | namespace detail | |
31 | { | |
32 | ||
33 | #if !BOOST_MP11_WORKAROUND( BOOST_MP11_MSVC, < 1930 ) | |
34 | ||
35 | template<class T> using mpmf_wrap = mp_identity<T>; | |
36 | template<class T> using mpmf_unwrap = typename T::type; | |
37 | ||
38 | #else | |
39 | ||
40 | template<class... T> struct mpmf_tuple {}; | |
41 | ||
42 | template<class T> struct mpmf_wrap_impl | |
43 | { | |
44 | using type = mp_identity<T>; | |
45 | }; | |
46 | ||
47 | template<class... T> struct mpmf_wrap_impl< std::tuple<T...> > | |
48 | { | |
49 | using type = mp_identity< mpmf_tuple<T...> >; | |
50 | }; | |
51 | ||
52 | template<class T> using mpmf_wrap = typename mpmf_wrap_impl<T>::type; | |
53 | ||
54 | template<class T> struct mpmf_unwrap_impl | |
55 | { | |
56 | using type = typename T::type; | |
57 | }; | |
58 | ||
59 | template<class... T> struct mpmf_unwrap_impl< mp_identity< mpmf_tuple<T...> > > | |
60 | { | |
61 | using type = std::tuple<T...>; | |
62 | }; | |
63 | ||
64 | template<class T> using mpmf_unwrap = typename mpmf_unwrap_impl<T>::type; | |
65 | ||
66 | #endif // #if !BOOST_MP11_WORKAROUND( BOOST_MP11_MSVC, < 1930 ) | |
67 | ||
68 | template<class M, class K> struct mp_map_find_impl; | |
69 | ||
70 | template<template<class...> class M, class... T, class K> struct mp_map_find_impl<M<T...>, K> | |
71 | { | |
72 | using U = mp_inherit<mpmf_wrap<T>...>; | |
73 | ||
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( ... ); | |
76 | ||
77 | using type = mpmf_unwrap< decltype( f((U*)0) ) >; | |
78 | }; | |
79 | ||
80 | } // namespace detail | |
81 | ||
82 | template<class M, class K> using mp_map_find = typename detail::mp_map_find_impl<M, K>::type; | |
83 | ||
84 | } // namespace mp11 | |
85 | } // namespace boost | |
86 | ||
87 | #endif // #ifndef BOOST_MP11_DETAIL_MP_MAP_FIND_HPP_INCLUDED |