Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:33:20

0001 /*=============================================================================
0002     Copyright (c) 2001-2011 Joel de Guzman
0003 
0004     Distributed under the Boost Software License, Version 1.0. (See accompanying
0005     file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0006 ==============================================================================*/
0007 #if !defined(FUSION_AT_IMPL_07172005_0726)
0008 #define FUSION_AT_IMPL_07172005_0726
0009 
0010 #include <boost/fusion/support/config.hpp>
0011 #include <boost/fusion/support/detail/access.hpp>
0012 #include <boost/type_traits/is_const.hpp>
0013 #include <boost/type_traits/add_const.hpp>
0014 #include <boost/mpl/if.hpp>
0015 #include <boost/mpl/bool.hpp>
0016 
0017 namespace boost { namespace fusion
0018 {
0019     namespace detail
0020     {
0021         template <typename Cons>
0022         struct cons_deref
0023         {
0024             typedef typename Cons::car_type type;
0025         };
0026 
0027         template <typename Cons, int I>
0028         struct cons_advance
0029         {
0030             typedef typename
0031                 cons_advance<Cons, I-1>::type::cdr_type
0032             type;
0033         };
0034 
0035         template <typename Cons>
0036         struct cons_advance<Cons, 0>
0037         {
0038             typedef Cons type;
0039         };
0040 
0041         template <typename Cons>
0042         struct cons_advance<Cons, 1>
0043         {
0044             typedef typename Cons::cdr_type type;
0045         };
0046 
0047         template <typename Cons>
0048         struct cons_advance<Cons, 2>
0049         {
0050 #if BOOST_WORKAROUND(BOOST_MSVC, > 1400) // VC8 and above
0051             typedef typename Cons::cdr_type::cdr_type type;
0052 #else
0053             typedef typename Cons::cdr_type _a;
0054             typedef typename _a::cdr_type type;
0055 #endif
0056         };
0057 
0058         template <typename Cons>
0059         struct cons_advance<Cons, 3>
0060         {
0061 #if BOOST_WORKAROUND(BOOST_MSVC, > 1400) // VC8 and above
0062             typedef typename Cons::cdr_type::cdr_type::cdr_type type;
0063 #else
0064             typedef typename Cons::cdr_type _a;
0065             typedef typename _a::cdr_type _b;
0066             typedef typename _b::cdr_type type;
0067 #endif
0068         };
0069 
0070         template <typename Cons>
0071         struct cons_advance<Cons, 4>
0072         {
0073 #if BOOST_WORKAROUND(BOOST_MSVC, > 1400) // VC8 and above
0074             typedef typename Cons::cdr_type::cdr_type::cdr_type::cdr_type type;
0075 #else
0076             typedef typename Cons::cdr_type _a;
0077             typedef typename _a::cdr_type _b;
0078             typedef typename _b::cdr_type _c;
0079             typedef typename _c::cdr_type type;
0080 #endif
0081         };
0082     }
0083 
0084     struct cons_tag;
0085 
0086     namespace extension
0087     {
0088         template <typename Tag>
0089         struct at_impl;
0090 
0091         template <>
0092         struct at_impl<cons_tag>
0093         {
0094             template <typename Sequence, typename N>
0095             struct apply
0096             {
0097                 typedef typename detail::cons_deref<
0098                     typename detail::cons_advance<Sequence, N::value>::type>::type
0099                 element;
0100 
0101                 typedef typename
0102                     mpl::if_<
0103                         is_const<Sequence>
0104                       , typename detail::cref_result<element>::type
0105                       , typename detail::ref_result<element>::type
0106                     >::type
0107                 type;
0108 
0109                 template <typename Cons, int N2>
0110                 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0111                 static type
0112                 call(Cons& s, mpl::int_<N2>)
0113                 {
0114                     return call(s.cdr, mpl::int_<N2-1>());
0115                 }
0116 
0117                 template <typename Cons>
0118                 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0119                 static type
0120                 call(Cons& s, mpl::int_<0>)
0121                 {
0122                     return s.car;
0123                 }
0124 
0125                 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0126                 static type
0127                 call(Sequence& s)
0128                 {
0129                     return call(s, mpl::int_<N::value>());
0130                 }
0131             };
0132         };
0133     }
0134 }}
0135 
0136 #endif