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