fix doc example typo
[boost.git] / boost / fusion / container / deque / detail / at_impl.hpp
blob3dc7cde99f3142f4fece91257645ebf18791e9a4
1 /*=============================================================================
2 Copyright (c) 2001-2006 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/container/deque/detail/keyed_element.hpp>
13 #include <boost/mpl/eval_if.hpp>
14 #include <boost/mpl/equal_to.hpp>
15 #include <boost/mpl/assert.hpp>
16 #include <boost/mpl/identity.hpp>
18 #include <boost/type_traits/is_const.hpp>
19 #include <boost/type_traits/add_const.hpp>
20 #include <boost/type_traits/add_reference.hpp>
22 namespace boost { namespace fusion {
24 struct deque_tag;
26 namespace extension
28 template<typename T>
29 struct at_impl;
31 template<>
32 struct at_impl<deque_tag>
34 template<typename Sequence, typename N>
35 struct apply
37 typedef typename Sequence::next_up next_up;
38 typedef typename Sequence::next_down next_down;
39 BOOST_MPL_ASSERT_RELATION(next_down::value, !=, next_up::value);
41 typedef mpl::plus<next_down, mpl::int_<1> > offset;
42 typedef mpl::int_<mpl::plus<N, offset>::value> adjusted_index;
43 typedef typename detail::keyed_element_value_at<Sequence, adjusted_index>::type element_type;
44 typedef typename add_reference<
45 typename mpl::eval_if<
46 is_const<Sequence>,
47 add_const<element_type>,
48 mpl::identity<element_type> >::type>::type type;
50 static type call(Sequence& seq)
52 return seq.get(adjusted_index());
59 #endif