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@101
|
11 #include <boost/fusion/support/config.hpp>
|
Chris@16
|
12 #include <boost/fusion/container/deque/detail/keyed_element.hpp>
|
Chris@16
|
13
|
Chris@16
|
14 #include <boost/mpl/eval_if.hpp>
|
Chris@16
|
15 #include <boost/mpl/equal_to.hpp>
|
Chris@16
|
16 #include <boost/mpl/assert.hpp>
|
Chris@16
|
17 #include <boost/mpl/identity.hpp>
|
Chris@16
|
18
|
Chris@16
|
19 #include <boost/type_traits/is_const.hpp>
|
Chris@16
|
20 #include <boost/type_traits/add_const.hpp>
|
Chris@16
|
21 #include <boost/type_traits/add_reference.hpp>
|
Chris@16
|
22
|
Chris@16
|
23 namespace boost { namespace fusion
|
Chris@16
|
24 {
|
Chris@16
|
25 struct deque_tag;
|
Chris@16
|
26
|
Chris@16
|
27 namespace extension
|
Chris@16
|
28 {
|
Chris@16
|
29 template<typename T>
|
Chris@16
|
30 struct at_impl;
|
Chris@16
|
31
|
Chris@16
|
32 template<>
|
Chris@16
|
33 struct at_impl<deque_tag>
|
Chris@16
|
34 {
|
Chris@16
|
35 template<typename Sequence, typename N>
|
Chris@16
|
36 struct apply
|
Chris@16
|
37 {
|
Chris@16
|
38 typedef typename Sequence::next_up next_up;
|
Chris@16
|
39 typedef typename Sequence::next_down next_down;
|
Chris@16
|
40 BOOST_MPL_ASSERT_RELATION(next_down::value, !=, next_up::value);
|
Chris@16
|
41
|
Chris@16
|
42 static int const offset = next_down::value + 1;
|
Chris@16
|
43 typedef mpl::int_<(N::value + offset)> adjusted_index;
|
Chris@16
|
44 typedef typename
|
Chris@16
|
45 detail::keyed_element_value_at<Sequence, adjusted_index>::type
|
Chris@16
|
46 element_type;
|
Chris@16
|
47
|
Chris@16
|
48 typedef typename
|
Chris@16
|
49 add_reference<
|
Chris@16
|
50 typename mpl::eval_if<
|
Chris@16
|
51 is_const<Sequence>,
|
Chris@16
|
52 add_const<element_type>,
|
Chris@16
|
53 mpl::identity<element_type> >::type
|
Chris@16
|
54 >::type
|
Chris@16
|
55 type;
|
Chris@16
|
56
|
Chris@101
|
57 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
Chris@16
|
58 static type call(Sequence& seq)
|
Chris@16
|
59 {
|
Chris@16
|
60 return seq.get(adjusted_index());
|
Chris@16
|
61 }
|
Chris@16
|
62 };
|
Chris@16
|
63 };
|
Chris@16
|
64 }
|
Chris@16
|
65 }}
|
Chris@16
|
66
|
Chris@16
|
67 #endif
|