]>
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_JOINT_VIEW_07162005_0140) | |
8 | #define FUSION_JOINT_VIEW_07162005_0140 | |
9 | ||
10 | #include <boost/fusion/support/config.hpp> | |
11 | #include <boost/fusion/view/joint_view/joint_view_fwd.hpp> | |
12 | #include <boost/fusion/support/detail/access.hpp> | |
13 | #include <boost/fusion/support/is_view.hpp> | |
14 | #include <boost/fusion/sequence/intrinsic/begin.hpp> | |
15 | #include <boost/fusion/sequence/intrinsic/end.hpp> | |
16 | #include <boost/fusion/sequence/intrinsic/size.hpp> | |
17 | #include <boost/fusion/view/joint_view/joint_view_iterator.hpp> | |
18 | #include <boost/fusion/view/joint_view/detail/begin_impl.hpp> | |
19 | #include <boost/fusion/view/joint_view/detail/end_impl.hpp> | |
20 | #include <boost/fusion/support/sequence_base.hpp> | |
21 | #include <boost/mpl/if.hpp> | |
22 | #include <boost/mpl/plus.hpp> | |
23 | #include <boost/mpl/bool.hpp> | |
24 | #include <boost/mpl/eval_if.hpp> | |
25 | #include <boost/mpl/inherit.hpp> | |
26 | #include <boost/mpl/identity.hpp> | |
27 | ||
28 | namespace boost { namespace fusion | |
29 | { | |
30 | struct joint_view_tag; | |
31 | struct forward_traversal_tag; | |
32 | struct fusion_sequence_tag; | |
33 | ||
34 | template <typename Sequence1, typename Sequence2> | |
35 | struct joint_view : sequence_base<joint_view<Sequence1, Sequence2> > | |
36 | { | |
37 | typedef joint_view_tag fusion_tag; | |
38 | typedef fusion_sequence_tag tag; // this gets picked up by MPL | |
39 | typedef typename | |
40 | mpl::eval_if< | |
41 | mpl::and_< | |
42 | traits::is_associative<Sequence1> | |
43 | , traits::is_associative<Sequence2> | |
44 | > | |
45 | , mpl::inherit2<forward_traversal_tag,associative_tag> | |
46 | , mpl::identity<forward_traversal_tag> | |
47 | >::type | |
48 | category; | |
49 | typedef mpl::true_ is_view; | |
50 | ||
51 | typedef typename result_of::begin<Sequence1>::type first_type; | |
52 | typedef typename result_of::end<Sequence1>::type last_type; | |
53 | typedef typename result_of::begin<Sequence2>::type concat_type; | |
54 | typedef typename result_of::end<Sequence2>::type concat_last_type; | |
55 | typedef typename mpl::int_< | |
56 | result_of::size<Sequence1>::value + result_of::size<Sequence2>::value> | |
57 | size; | |
58 | ||
59 | BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED | |
60 | joint_view(Sequence1& in_seq1, Sequence2& in_seq2) | |
61 | : seq1(in_seq1) | |
62 | , seq2(in_seq2) | |
63 | {} | |
64 | ||
65 | BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED | |
66 | first_type first() const { return fusion::begin(seq1); } | |
67 | BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED | |
68 | concat_type concat() const { return fusion::begin(seq2); } | |
69 | BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED | |
70 | concat_last_type concat_last() const { return fusion::end(seq2); } | |
71 | ||
72 | private: | |
73 | // silence MSVC warning C4512: assignment operator could not be generated | |
74 | joint_view& operator= (joint_view const&); | |
75 | ||
76 | typename mpl::if_<traits::is_view<Sequence1>, Sequence1, Sequence1&>::type seq1; | |
77 | typename mpl::if_<traits::is_view<Sequence2>, Sequence2, Sequence2&>::type seq2; | |
78 | }; | |
79 | }} | |
80 | ||
81 | #endif | |
82 | ||
83 |