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(BOOST_FUSION_AT_KEY_20060304_1755)
0009 #define BOOST_FUSION_AT_KEY_20060304_1755
0010 
0011 #include <boost/fusion/support/config.hpp>
0012 #include <boost/type_traits/is_const.hpp>
0013 #include <boost/fusion/sequence/intrinsic_fwd.hpp>
0014 #include <boost/fusion/sequence/intrinsic/has_key.hpp>
0015 #include <boost/fusion/algorithm/query/find.hpp>
0016 #include <boost/fusion/iterator/deref_data.hpp>
0017 #include <boost/fusion/support/tag_of.hpp>
0018 #include <boost/fusion/support/category_of.hpp>
0019 #include <boost/fusion/support/detail/access.hpp>
0020 #include <boost/mpl/empty_base.hpp>
0021 #include <boost/mpl/if.hpp>
0022 #include <boost/mpl/or.hpp>
0023 
0024 namespace boost { namespace fusion
0025 {
0026     // Special tags:
0027     struct sequence_facade_tag;
0028     struct boost_array_tag; // boost::array tag
0029     struct mpl_sequence_tag; // mpl sequence tag
0030     struct std_pair_tag; // std::pair tag
0031 
0032     namespace extension
0033     {
0034         template <typename Tag>
0035         struct at_key_impl
0036         {
0037             template <typename Seq, typename Key>
0038             struct apply
0039             {
0040                 typedef typename
0041                     result_of::deref_data<
0042                         typename result_of::find<Seq, Key>::type
0043                     >::type
0044                 type;
0045 
0046                 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0047                 static type
0048                 call(Seq& seq)
0049                 {
0050                     return fusion::deref_data(fusion::find<Key>(seq));
0051                 }
0052             };
0053         };
0054 
0055         template <>
0056         struct at_key_impl<sequence_facade_tag>
0057         {
0058             template <typename Sequence, typename Key>
0059             struct apply : Sequence::template at_key_impl<Sequence, Key> {};
0060         };
0061 
0062         template <>
0063         struct at_key_impl<boost_array_tag>;
0064 
0065         template <>
0066         struct at_key_impl<mpl_sequence_tag>;
0067 
0068         template <>
0069         struct at_key_impl<std_pair_tag>;
0070     }
0071 
0072     namespace detail
0073     {
0074         template <typename Sequence, typename Key, typename Tag>
0075         struct at_key_impl
0076             : mpl::if_<
0077                   mpl::or_<
0078                       typename extension::has_key_impl<Tag>::template apply<Sequence, Key>
0079                     , traits::is_unbounded<Sequence>
0080                   >
0081                 , typename extension::at_key_impl<Tag>::template apply<Sequence, Key>
0082                 , mpl::empty_base
0083               >::type
0084         {};
0085     }
0086 
0087     namespace result_of
0088     {
0089         template <typename Sequence, typename Key>
0090         struct at_key
0091             : detail::at_key_impl<Sequence, Key, typename detail::tag_of<Sequence>::type>
0092         {};
0093     }
0094 
0095     template <typename Key, typename Sequence>
0096     BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0097     inline typename 
0098         lazy_disable_if<
0099             is_const<Sequence>
0100           , result_of::at_key<Sequence, Key>
0101         >::type
0102     at_key(Sequence& seq)
0103     {
0104         return result_of::at_key<Sequence, Key>::call(seq);
0105     }
0106 
0107     template <typename Key, typename Sequence>
0108     BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0109     inline typename result_of::at_key<Sequence const, Key>::type
0110     at_key(Sequence const& seq)
0111     {
0112         return result_of::at_key<Sequence const, Key>::call(seq);
0113     }
0114 }}
0115 
0116 #endif