Chris@16
|
1 /*=============================================================================
|
Chris@16
|
2 Copyright (c) 2005-2012 Joel de Guzman
|
Chris@16
|
3 Copyright (c) 2005-2006 Dan Marsden
|
Chris@16
|
4
|
Chris@16
|
5 Distributed under the Boost Software License, Version 1.0. (See accompanying
|
Chris@16
|
6 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
7 ==============================================================================*/
|
Chris@16
|
8 #if !defined(BOOST_FUSION_DEQUE_AT_IMPL_09122006_2017)
|
Chris@16
|
9 #define BOOST_FUSION_DEQUE_AT_IMPL_09122006_2017
|
Chris@16
|
10
|
Chris@16
|
11 #include <boost/fusion/container/deque/detail/keyed_element.hpp>
|
Chris@16
|
12
|
Chris@16
|
13 #include <boost/mpl/eval_if.hpp>
|
Chris@16
|
14 #include <boost/mpl/equal_to.hpp>
|
Chris@16
|
15 #include <boost/mpl/assert.hpp>
|
Chris@16
|
16 #include <boost/mpl/identity.hpp>
|
Chris@16
|
17
|
Chris@16
|
18 #include <boost/type_traits/is_const.hpp>
|
Chris@16
|
19 #include <boost/type_traits/add_const.hpp>
|
Chris@16
|
20 #include <boost/type_traits/add_reference.hpp>
|
Chris@16
|
21
|
Chris@16
|
22 namespace boost { namespace fusion
|
Chris@16
|
23 {
|
Chris@16
|
24 struct deque_tag;
|
Chris@16
|
25
|
Chris@16
|
26 namespace extension
|
Chris@16
|
27 {
|
Chris@16
|
28 template<typename T>
|
Chris@16
|
29 struct at_impl;
|
Chris@16
|
30
|
Chris@16
|
31 template<>
|
Chris@16
|
32 struct at_impl<deque_tag>
|
Chris@16
|
33 {
|
Chris@16
|
34 template<typename Sequence, typename N>
|
Chris@16
|
35 struct apply
|
Chris@16
|
36 {
|
Chris@16
|
37 typedef typename Sequence::next_up next_up;
|
Chris@16
|
38 typedef typename Sequence::next_down next_down;
|
Chris@16
|
39 BOOST_MPL_ASSERT_RELATION(next_down::value, !=, next_up::value);
|
Chris@16
|
40
|
Chris@16
|
41 static int const offset = next_down::value + 1;
|
Chris@16
|
42 typedef mpl::int_<(N::value + offset)> adjusted_index;
|
Chris@16
|
43 typedef typename
|
Chris@16
|
44 detail::keyed_element_value_at<Sequence, adjusted_index>::type
|
Chris@16
|
45 element_type;
|
Chris@16
|
46
|
Chris@16
|
47 typedef typename
|
Chris@16
|
48 add_reference<
|
Chris@16
|
49 typename mpl::eval_if<
|
Chris@16
|
50 is_const<Sequence>,
|
Chris@16
|
51 add_const<element_type>,
|
Chris@16
|
52 mpl::identity<element_type> >::type
|
Chris@16
|
53 >::type
|
Chris@16
|
54 type;
|
Chris@16
|
55
|
Chris@16
|
56 static type call(Sequence& seq)
|
Chris@16
|
57 {
|
Chris@16
|
58 return seq.get(adjusted_index());
|
Chris@16
|
59 }
|
Chris@16
|
60 };
|
Chris@16
|
61 };
|
Chris@16
|
62 }
|
Chris@16
|
63 }}
|
Chris@16
|
64
|
Chris@16
|
65 #endif
|