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