1 /*=============================================================================
2 Copyright (c) 2001-2006 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/detail/access.hpp>
11 #include <boost/type_traits/is_const.hpp>
12 #include <boost/type_traits/add_const.hpp>
13 #include <boost/mpl/eval_if.hpp>
14 #include <boost/mpl/bool.hpp>
16 namespace boost
{ namespace fusion
20 template <typename Cons
>
23 typedef typename
Cons::car_type type
;
26 template <typename Cons
, int I
>
30 cons_advance
<Cons
, I
-1>::type::cdr_type
34 template <typename Cons
>
35 struct cons_advance
<Cons
, 0>
40 template <typename Cons
>
41 struct cons_advance
<Cons
, 1>
43 typedef typename
Cons::cdr_type type
;
46 template <typename Cons
>
47 struct cons_advance
<Cons
, 2>
49 #if BOOST_WORKAROUND(BOOST_MSVC, > 1400) // VC8 and above
50 typedef typename
Cons::cdr_type::cdr_type type
;
52 typedef typename
Cons::cdr_type _a
;
53 typedef typename
_a::cdr_type type
;
57 template <typename Cons
>
58 struct cons_advance
<Cons
, 3>
60 #if BOOST_WORKAROUND(BOOST_MSVC, > 1400) // VC8 and above
61 typedef typename
Cons::cdr_type::cdr_type::cdr_type type
;
63 typedef typename
Cons::cdr_type _a
;
64 typedef typename
_a::cdr_type _b
;
65 typedef typename
_b::cdr_type type
;
69 template <typename Cons
>
70 struct cons_advance
<Cons
, 4>
72 #if BOOST_WORKAROUND(BOOST_MSVC, > 1400) // VC8 and above
73 typedef typename
Cons::cdr_type::cdr_type::cdr_type::cdr_type type
;
75 typedef typename
Cons::cdr_type _a
;
76 typedef typename
_a::cdr_type _b
;
77 typedef typename
_b::cdr_type _c
;
78 typedef typename
_c::cdr_type type
;
87 template <typename Tag
>
91 struct at_impl
<cons_tag
>
93 template <typename Sequence
, typename N
>
96 typedef detail::cons_deref
<
97 typename
detail::cons_advance
<Sequence
, N::value
>::type
>
103 , detail::cref_result
<element
>
104 , detail::ref_result
<element
>
108 template <typename Cons
, int N2
>
110 call(Cons
& s
, mpl::int_
<N2
>)
112 return call(s
.cdr
, mpl::int_
<N2
-1>());
115 template <typename Cons
>
117 call(Cons
& s
, mpl::int_
<0>)
125 return call(s
, mpl::int_
<N::value
>());