Imported Upstream version 1.57.0
[platform/upstream/boost.git] / boost / fusion / container / vector / detail / at_impl.hpp
1 /*=============================================================================
2     Copyright (c) 2001-2011 Joel de Guzman
3
4     Distributed under the Boost Software License, Version 1.0. (See accompanying
5     file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 ==============================================================================*/
7 #if !defined(FUSION_AT_IMPL_05042005_0741)
8 #define FUSION_AT_IMPL_05042005_0741
9
10 #include <boost/fusion/support/config.hpp>
11 #include <boost/fusion/support/detail/access.hpp>
12 #include <boost/type_traits/is_const.hpp>
13 #include <boost/mpl/at.hpp>
14 #include <boost/mpl/int.hpp>
15
16 namespace boost { namespace fusion
17 {
18     struct vector_tag;
19
20     namespace extension
21     {
22         template <typename Tag>
23         struct at_impl;
24
25         template <>
26         struct at_impl<vector_tag>
27         {
28             template <typename Sequence, typename N>
29             struct apply
30             {
31                 typedef typename mpl::at<typename Sequence::types, N>::type element;
32                 typedef typename detail::ref_result<element>::type type;
33
34                 BOOST_FUSION_GPU_ENABLED
35                 static type
36                 call(Sequence& v)
37                 {
38                     BOOST_STATIC_ASSERT((N::value < Sequence::size::value));
39                     return v.at_impl(N());
40                 }
41             };
42
43             template <typename Sequence, typename N>
44             struct apply <Sequence const, N>
45             {
46                 typedef typename mpl::at<typename Sequence::types, N>::type element;
47                 typedef typename detail::cref_result<element>::type type;
48
49                 BOOST_FUSION_GPU_ENABLED
50                 static type
51                 call(Sequence const& v)
52                 {
53                     BOOST_STATIC_ASSERT((N::value < Sequence::size::value));
54                     return v.at_impl(N());
55                 }
56             };
57         };
58     }
59 }}
60
61 #endif