1 /*=============================================================================
2 Copyright (c) 2005-2012 Joel de Guzman
3 Copyright (c) 2005-2006 Dan Marsden
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
11 #include <boost/fusion/support/config.hpp>
12 #include <boost/fusion/container/deque/detail/keyed_element.hpp>
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>
19 #include <boost/type_traits/is_const.hpp>
20 #include <boost/type_traits/add_const.hpp>
21 #include <boost/type_traits/add_reference.hpp>
23 namespace boost { namespace fusion
33 struct at_impl<deque_tag>
35 template<typename Sequence, typename N>
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);
42 static int const offset = next_down::value + 1;
43 typedef mpl::int_<(N::value + offset)> adjusted_index;
45 detail::keyed_element_value_at<Sequence, adjusted_index>::type
50 typename mpl::eval_if<
52 add_const<element_type>,
53 mpl::identity<element_type> >::type
57 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
58 static type call(Sequence& seq)
60 return seq.get(adjusted_index());