1 /*=============================================================================
2 Copyright (c) 2001-2011 Joel de Guzman
4 Distributed under the Boost Software License, Version 1.0. (See accompanying
5 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 ==============================================================================*/
7 #if !defined(FUSION_AT_IMPL_07172005_0726)
8 #define FUSION_AT_IMPL_07172005_0726
10 #include <boost/fusion/support/config.hpp>
11 #include <boost/fusion/support/detail/access.hpp>
12 #include <boost/type_traits/is_const.hpp>
13 #include <boost/type_traits/add_const.hpp>
14 #include <boost/mpl/if.hpp>
15 #include <boost/mpl/bool.hpp>
17 namespace boost { namespace fusion
21 template <typename Cons>
24 typedef typename Cons::car_type type;
27 template <typename Cons, int I>
31 cons_advance<Cons, I-1>::type::cdr_type
35 template <typename Cons>
36 struct cons_advance<Cons, 0>
41 template <typename Cons>
42 struct cons_advance<Cons, 1>
44 typedef typename Cons::cdr_type type;
47 template <typename Cons>
48 struct cons_advance<Cons, 2>
50 #if BOOST_WORKAROUND(BOOST_MSVC, > 1400) // VC8 and above
51 typedef typename Cons::cdr_type::cdr_type type;
53 typedef typename Cons::cdr_type _a;
54 typedef typename _a::cdr_type type;
58 template <typename Cons>
59 struct cons_advance<Cons, 3>
61 #if BOOST_WORKAROUND(BOOST_MSVC, > 1400) // VC8 and above
62 typedef typename Cons::cdr_type::cdr_type::cdr_type type;
64 typedef typename Cons::cdr_type _a;
65 typedef typename _a::cdr_type _b;
66 typedef typename _b::cdr_type type;
70 template <typename Cons>
71 struct cons_advance<Cons, 4>
73 #if BOOST_WORKAROUND(BOOST_MSVC, > 1400) // VC8 and above
74 typedef typename Cons::cdr_type::cdr_type::cdr_type::cdr_type type;
76 typedef typename Cons::cdr_type _a;
77 typedef typename _a::cdr_type _b;
78 typedef typename _b::cdr_type _c;
79 typedef typename _c::cdr_type type;
88 template <typename Tag>
92 struct at_impl<cons_tag>
94 template <typename Sequence, typename N>
97 typedef typename detail::cons_deref<
98 typename detail::cons_advance<Sequence, N::value>::type>::type
104 , typename detail::cref_result<element>::type
105 , typename detail::ref_result<element>::type
109 template <typename Cons, int N2>
110 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
112 call(Cons& s, mpl::int_<N2>)
114 return call(s.cdr, mpl::int_<N2-1>());
117 template <typename Cons>
118 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
120 call(Cons& s, mpl::int_<0>)
125 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
129 return call(s, mpl::int_<N::value>());