]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
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_REVERSE_VIEW_07202005_0836) | |
8 | #define FUSION_REVERSE_VIEW_07202005_0836 | |
9 | ||
10 | #include <boost/fusion/support/config.hpp> | |
11 | #include <boost/fusion/support/detail/access.hpp> | |
12 | #include <boost/fusion/support/is_view.hpp> | |
13 | #include <boost/fusion/support/category_of.hpp> | |
14 | #include <boost/fusion/view/reverse_view/reverse_view_iterator.hpp> | |
15 | #include <boost/fusion/view/reverse_view/detail/begin_impl.hpp> | |
16 | #include <boost/fusion/view/reverse_view/detail/end_impl.hpp> | |
17 | #include <boost/fusion/view/reverse_view/detail/at_impl.hpp> | |
18 | #include <boost/fusion/view/reverse_view/detail/value_at_impl.hpp> | |
19 | #include <boost/fusion/support/sequence_base.hpp> | |
20 | #include <boost/fusion/sequence/intrinsic/begin.hpp> | |
21 | #include <boost/fusion/sequence/intrinsic/end.hpp> | |
22 | #include <boost/fusion/sequence/intrinsic/size.hpp> | |
23 | #include <boost/type_traits/is_base_of.hpp> | |
24 | #include <boost/static_assert.hpp> | |
25 | #include <boost/mpl/bool.hpp> | |
26 | #include <boost/mpl/eval_if.hpp> | |
27 | #include <boost/mpl/inherit.hpp> | |
28 | #include <boost/mpl/identity.hpp> | |
29 | ||
30 | namespace boost { namespace fusion | |
31 | { | |
32 | struct reverse_view_tag; | |
33 | struct fusion_sequence_tag; | |
34 | ||
35 | template <typename Sequence> | |
36 | struct reverse_view : sequence_base<reverse_view<Sequence> > | |
37 | { | |
38 | typedef reverse_view_tag fusion_tag; | |
39 | typedef fusion_sequence_tag tag; // this gets picked up by MPL | |
40 | typedef mpl::true_ is_view; | |
41 | ||
42 | typedef Sequence seq_type; | |
43 | typedef typename traits::category_of<Sequence>::type category; | |
44 | typedef typename result_of::begin<Sequence>::type first_type; | |
45 | typedef typename result_of::end<Sequence>::type last_type; | |
46 | typedef typename result_of::size<Sequence>::type size; | |
47 | ||
48 | BOOST_STATIC_ASSERT(( | |
49 | is_base_of< | |
50 | bidirectional_traversal_tag | |
51 | , typename traits::category_of<first_type>::type>::value)); | |
52 | ||
53 | BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED | |
54 | reverse_view(Sequence& in_seq) | |
55 | : seq(in_seq) | |
56 | {} | |
57 | ||
58 | BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED | |
59 | first_type first() const { return fusion::begin(seq); } | |
60 | BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED | |
61 | last_type last() const { return fusion::end(seq); } | |
62 | typename mpl::if_<traits::is_view<Sequence>, Sequence, Sequence&>::type seq; | |
63 | ||
64 | private: | |
65 | // silence MSVC warning C4512: assignment operator could not be generated | |
66 | reverse_view& operator= (reverse_view const&); | |
67 | }; | |
68 | }} | |
69 | ||
70 | #endif | |
71 | ||
72 |