Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:34:42

0001 /*=============================================================================
0002     Copyright (c) 2001-2011 Joel de Guzman
0003     Copyright (c) 2006 Dan Marsden
0004 
0005     Distributed under the Boost Software License, Version 1.0. (See accompanying 
0006     file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0007 ==============================================================================*/
0008 #if !defined(FUSION_VALUE_AT_KEY_05052005_0229)
0009 #define FUSION_VALUE_AT_KEY_05052005_0229
0010 
0011 #include <boost/fusion/support/config.hpp>
0012 #include <boost/mpl/int.hpp>
0013 #include <boost/mpl/empty_base.hpp>
0014 #include <boost/mpl/if.hpp>
0015 #include <boost/mpl/or.hpp>
0016 #include <boost/fusion/sequence/intrinsic_fwd.hpp>
0017 #include <boost/fusion/sequence/intrinsic/has_key.hpp>
0018 #include <boost/fusion/iterator/value_of_data.hpp>
0019 #include <boost/fusion/algorithm/query/find.hpp>
0020 #include <boost/fusion/support/tag_of.hpp>
0021 #include <boost/fusion/support/category_of.hpp>
0022 
0023 namespace boost { namespace fusion
0024 {
0025     // Special tags:
0026     struct sequence_facade_tag;
0027     struct boost_array_tag; // boost::array tag
0028     struct mpl_sequence_tag; // mpl sequence tag
0029     struct std_pair_tag; // std::pair tag
0030 
0031     namespace extension
0032     {
0033         template <typename Tag>
0034         struct value_at_key_impl
0035         {
0036             template <typename Seq, typename Key>
0037             struct apply
0038               : result_of::value_of_data<
0039                     typename result_of::find<Seq, Key>::type
0040                 >
0041             {};
0042         };
0043 
0044         template <>
0045         struct value_at_key_impl<sequence_facade_tag>
0046         {
0047             template <typename Sequence, typename Key>
0048             struct apply : Sequence::template value_at_key<Sequence, Key> {};
0049         };
0050 
0051         template <>
0052         struct value_at_key_impl<boost_array_tag>;
0053 
0054         template <>
0055         struct value_at_key_impl<mpl_sequence_tag>;
0056 
0057         template <>
0058         struct value_at_key_impl<std_pair_tag>;
0059     }
0060 
0061     namespace detail
0062     {
0063         template <typename Sequence, typename N, typename Tag>
0064         struct value_at_key_impl
0065             : mpl::if_<
0066                   mpl::or_<
0067                       typename extension::has_key_impl<Tag>::template apply<Sequence, N>
0068                     , traits::is_unbounded<Sequence>
0069                   >
0070                 , typename extension::value_at_key_impl<Tag>::template apply<Sequence, N>
0071                 , mpl::empty_base
0072               >::type
0073         {};
0074     }
0075 
0076     namespace result_of
0077     {
0078         template <typename Sequence, typename N>
0079         struct value_at_key
0080             : detail::value_at_key_impl<Sequence, N, typename detail::tag_of<Sequence>::type>
0081         {};
0082     }
0083 }}
0084 
0085 #endif
0086