Chris@16
|
1 /*=============================================================================
|
Chris@16
|
2 Copyright (c) 2001-2011 Joel de Guzman
|
Chris@16
|
3 Copyright (c) 2006 Dan Marsden
|
Chris@16
|
4
|
Chris@16
|
5 Distributed under the Boost Software License, Version 1.0. (See accompanying
|
Chris@16
|
6 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
7 ==============================================================================*/
|
Chris@16
|
8 #if !defined(FUSION_VALUE_AT_KEY_05052005_0229)
|
Chris@16
|
9 #define FUSION_VALUE_AT_KEY_05052005_0229
|
Chris@16
|
10
|
Chris@101
|
11 #include <boost/fusion/support/config.hpp>
|
Chris@16
|
12 #include <boost/mpl/int.hpp>
|
Chris@16
|
13 #include <boost/fusion/sequence/intrinsic_fwd.hpp>
|
Chris@16
|
14 #include <boost/fusion/iterator/value_of_data.hpp>
|
Chris@16
|
15 #include <boost/fusion/algorithm/query/find.hpp>
|
Chris@16
|
16 #include <boost/fusion/support/tag_of.hpp>
|
Chris@16
|
17
|
Chris@16
|
18 namespace boost { namespace fusion
|
Chris@16
|
19 {
|
Chris@16
|
20 // Special tags:
|
Chris@16
|
21 struct sequence_facade_tag;
|
Chris@16
|
22 struct boost_array_tag; // boost::array tag
|
Chris@16
|
23 struct mpl_sequence_tag; // mpl sequence tag
|
Chris@16
|
24 struct std_pair_tag; // std::pair tag
|
Chris@16
|
25
|
Chris@16
|
26 namespace extension
|
Chris@16
|
27 {
|
Chris@16
|
28 template <typename Tag>
|
Chris@16
|
29 struct value_at_key_impl
|
Chris@16
|
30 {
|
Chris@16
|
31 template <typename Seq, typename Key>
|
Chris@16
|
32 struct apply
|
Chris@16
|
33 : result_of::value_of_data<
|
Chris@16
|
34 typename result_of::find<Seq, Key>::type
|
Chris@16
|
35 >
|
Chris@16
|
36 {};
|
Chris@16
|
37 };
|
Chris@16
|
38
|
Chris@16
|
39 template <>
|
Chris@16
|
40 struct value_at_key_impl<sequence_facade_tag>
|
Chris@16
|
41 {
|
Chris@16
|
42 template <typename Sequence, typename Key>
|
Chris@16
|
43 struct apply : Sequence::template value_at_key<Sequence, Key> {};
|
Chris@16
|
44 };
|
Chris@16
|
45
|
Chris@16
|
46 template <>
|
Chris@16
|
47 struct value_at_key_impl<boost_array_tag>;
|
Chris@16
|
48
|
Chris@16
|
49 template <>
|
Chris@16
|
50 struct value_at_key_impl<mpl_sequence_tag>;
|
Chris@16
|
51
|
Chris@16
|
52 template <>
|
Chris@16
|
53 struct value_at_key_impl<std_pair_tag>;
|
Chris@16
|
54 }
|
Chris@16
|
55
|
Chris@16
|
56 namespace result_of
|
Chris@16
|
57 {
|
Chris@16
|
58 template <typename Sequence, typename N>
|
Chris@16
|
59 struct value_at_key
|
Chris@16
|
60 : extension::value_at_key_impl<typename detail::tag_of<Sequence>::type>::
|
Chris@16
|
61 template apply<Sequence, N>
|
Chris@16
|
62 {};
|
Chris@16
|
63 }
|
Chris@16
|
64 }}
|
Chris@16
|
65
|
Chris@16
|
66 #endif
|
Chris@16
|
67
|