Imported Upstream version 1.57.0
[platform/upstream/boost.git] / boost / fusion / container / map / detail / at_key_impl.hpp
1 /*=============================================================================
2     Copyright (c) 2001-2013 Joel de Guzman
3
4     Distributed under the Boost Software License, Version 1.0. (See accompanying
5     file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 ==============================================================================*/
7 #if !defined(BOOST_FUSION_MAP_DETAIL_AT_KEY_IMPL_02042013_0821)
8 #define BOOST_FUSION_MAP_DETAIL_AT_KEY_IMPL_02042013_0821
9
10 #include <boost/fusion/support/config.hpp>
11 #include <boost/fusion/support/detail/access.hpp>
12 #include <boost/type_traits/is_const.hpp>
13 #include <boost/mpl/at.hpp>
14 #include <boost/mpl/identity.hpp>
15
16 namespace boost { namespace fusion
17 {
18     struct map_tag;
19
20     namespace extension
21     {
22         template <typename Tag>
23         struct at_key_impl;
24
25         template <>
26         struct at_key_impl<map_tag>
27         {
28             template <typename Sequence, typename Key>
29             struct apply
30             {
31                 typedef
32                     decltype(std::declval<Sequence>().get(mpl::identity<Key>()))
33                 type;
34
35                 BOOST_FUSION_GPU_ENABLED
36                 static type
37                 call(Sequence& m)
38                 {
39                     return m.get(mpl::identity<Key>());
40                 }
41             };
42
43             template <typename Sequence, typename Key>
44             struct apply<Sequence const, Key>
45             {
46                 typedef
47                     decltype(std::declval<Sequence const>().get(mpl::identity<Key>()))
48                 type;
49
50                 BOOST_FUSION_GPU_ENABLED
51                 static type
52                 call(Sequence const& m)
53                 {
54                     return m.get(mpl::identity<Key>());
55                 }
56             };
57         };
58     }
59 }}
60
61 #endif