1 /*=============================================================================
2 Copyright (c) 2001-2011 Joel de Guzman
3 Copyright (c) 2006 Dan Marsden
5 Distributed under the Boost Software License, Version 1.0. (See accompanying
6 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 ==============================================================================*/
8 #if !defined(FUSION_VALUE_AT_KEY_05052005_0229)
9 #define FUSION_VALUE_AT_KEY_05052005_0229
11 #include <boost/fusion/support/config.hpp>
12 #include <boost/mpl/int.hpp>
13 #include <boost/mpl/empty_base.hpp>
14 #include <boost/mpl/if.hpp>
15 #include <boost/mpl/or.hpp>
16 #include <boost/fusion/sequence/intrinsic_fwd.hpp>
17 #include <boost/fusion/sequence/intrinsic/has_key.hpp>
18 #include <boost/fusion/iterator/value_of_data.hpp>
19 #include <boost/fusion/algorithm/query/find.hpp>
20 #include <boost/fusion/support/tag_of.hpp>
21 #include <boost/fusion/support/category_of.hpp>
23 namespace boost { namespace fusion
26 struct sequence_facade_tag;
27 struct boost_array_tag; // boost::array tag
28 struct mpl_sequence_tag; // mpl sequence tag
29 struct std_pair_tag; // std::pair tag
33 template <typename Tag>
34 struct value_at_key_impl
36 template <typename Seq, typename Key>
38 : result_of::value_of_data<
39 typename result_of::find<Seq, Key>::type
45 struct value_at_key_impl<sequence_facade_tag>
47 template <typename Sequence, typename Key>
48 struct apply : Sequence::template value_at_key<Sequence, Key> {};
52 struct value_at_key_impl<boost_array_tag>;
55 struct value_at_key_impl<mpl_sequence_tag>;
58 struct value_at_key_impl<std_pair_tag>;
63 template <typename Sequence, typename N, typename Tag>
64 struct value_at_key_impl
67 typename extension::has_key_impl<Tag>::template apply<Sequence, N>
68 , traits::is_unbounded<Sequence>
70 , typename extension::value_at_key_impl<Tag>::template apply<Sequence, N>
78 template <typename Sequence, typename N>
80 : detail::value_at_key_impl<Sequence, N, typename detail::tag_of<Sequence>::type>