PageRenderTime 19ms CodeModel.GetById 9ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/Src/Dependencies/Boost/boost/fusion/container/deque/detail/at_impl.hpp

http://hadesmem.googlecode.com/
C++ Header | 59 lines | 42 code | 10 blank | 7 comment | 0 complexity | 07feb25a3617b5c4dbc121579ef75a58 MD5 | raw file
 1/*=============================================================================
 2    Copyright (c) 2001-2006 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/container/deque/detail/keyed_element.hpp>
12
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>
17
18#include <boost/type_traits/is_const.hpp>
19#include <boost/type_traits/add_const.hpp>
20#include <boost/type_traits/add_reference.hpp>
21
22namespace boost { namespace fusion { 
23
24    struct deque_tag;
25
26    namespace extension 
27    {
28        template<typename T>
29        struct at_impl;
30        
31        template<>
32        struct at_impl<deque_tag>
33        {
34            template<typename Sequence, typename N>
35            struct apply
36            {
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);
40                
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;
49
50                static type call(Sequence& seq)
51                {
52                    return seq.get(adjusted_index());
53                }
54            };
55        };
56    }
57}}
58
59#endif