075f0b0f1829b641bb05e21f050e385abb7f5d4a
[platform/upstream/boost.git] / boost / fusion / view / nview / detail / deref_impl.hpp
1 /*=============================================================================
2     Copyright (c) 2009 Hartmut Kaiser
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
8 #if !defined(BOOST_FUSION_NVIEW_DEREF_IMPL_SEP_24_2009_0818AM)
9 #define BOOST_FUSION_NVIEW_DEREF_IMPL_SEP_24_2009_0818AM
10
11 #include <boost/fusion/iterator/deref.hpp>
12 #include <boost/fusion/container/vector.hpp>
13
14 namespace boost { namespace fusion
15 {
16     struct nview_iterator_tag;
17
18     namespace extension
19     {
20         template<typename Tag>
21         struct deref_impl;
22
23         template<>
24         struct deref_impl<nview_iterator_tag>
25         {
26             template<typename Iterator>
27             struct apply
28             {
29                 typedef typename Iterator::first_type first_type;
30                 typedef typename Iterator::sequence_type sequence_type;
31
32                 typedef typename result_of::deref<first_type>::type index;
33                 typedef typename result_of::at<
34                     typename sequence_type::sequence_type, index>::type type;
35
36                 static type call(Iterator const& i)
37                 {
38                     return at<index>(i.seq.seq);
39                 }
40             };
41         };
42
43     }
44
45 }}
46
47 #endif
48