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#ifdef _MSC_VER
29# pragma warning(push)
30# pragma warning(disable: 4512) // assignment operator could not be generated.
31#endif
32
33namespace boost { namespace fusion
34{
35 struct joint_view_tag;
36 struct forward_traversal_tag;
37 struct fusion_sequence_tag;
38
39 template <typename Sequence1, typename Sequence2>
40 struct joint_view : sequence_base<joint_view<Sequence1, Sequence2> >
41 {
42 typedef joint_view_tag fusion_tag;
43 typedef fusion_sequence_tag tag; // this gets picked up by MPL
44 typedef typename
45 mpl::eval_if<
46 mpl::and_<
47 traits::is_associative<Sequence1>
48 , traits::is_associative<Sequence2>
49 >
50 , mpl::inherit2<forward_traversal_tag,associative_tag>
51 , mpl::identity<forward_traversal_tag>
52 >::type
53 category;
54 typedef mpl::true_ is_view;
55
56 typedef typename result_of::begin<Sequence1>::type first_type;
57 typedef typename result_of::end<Sequence1>::type last_type;
58 typedef typename result_of::begin<Sequence2>::type concat_type;
59 typedef typename result_of::end<Sequence2>::type concat_last_type;
60 typedef typename mpl::int_<
61 result_of::size<Sequence1>::value + result_of::size<Sequence2>::value>
62 size;
63
64 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
65 joint_view(Sequence1& in_seq1, Sequence2& in_seq2)
66 : seq1(in_seq1)
67 , seq2(in_seq2)
68 {}
69
70 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
71 first_type first() const { return fusion::begin(seq1); }
72 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
73 concat_type concat() const { return fusion::begin(seq2); }
74 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
75 concat_last_type concat_last() const { return fusion::end(seq2); }
76
77 private:
78 typename mpl::if_<traits::is_view<Sequence1>, Sequence1, Sequence1&>::type seq1;
79 typename mpl::if_<traits::is_view<Sequence2>, Sequence2, Sequence2&>::type seq2;
80 };
81}}
82
83#ifdef _MSC_VER
84# pragma warning(pop)
85#endif
86
87#endif
88
89
90