source: NonGTP/Boost/boost/spirit/fusion/sequence/detail/joint_view_begin_end_traits.hpp @ 857

Revision 857, 3.7 KB checked in by igarcia, 18 years ago (diff)
Line 
1/*=============================================================================
2    Copyright (c) 2003 Joel de Guzman
3    Copyright (c) 2004 Peder Holt
4
5    Use, modification and distribution is subject to the Boost Software
6    License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
7    http://www.boost.org/LICENSE_1_0.txt)
8==============================================================================*/
9#if !defined(FUSION_SEQUENCE_DETAIL_JOINT_VIEW_BEGIN_END_TRAITS_HPP)
10#define FUSION_SEQUENCE_DETAIL_JOINT_VIEW_BEGIN_END_TRAITS_HPP
11
12#include <boost/spirit/fusion/detail/config.hpp>
13#include <boost/spirit/fusion/iterator/equal_to.hpp>
14#include <boost/mpl/if.hpp>
15
16namespace boost { namespace fusion
17{
18    struct joint_view_tag;
19
20    template <typename View1, typename View2>
21    struct joint_view;
22
23    template <typename First, typename Last, typename Concat>
24    struct joint_view_iterator;
25
26    namespace joint_view_detail {
27        template <typename Sequence>
28        struct begin_traits_impl
29        {
30            typedef typename Sequence::first_type first_type;
31            typedef typename Sequence::last_type last_type;
32            typedef typename Sequence::concat_type concat_type;
33            typedef boost::fusion::meta::equal_to<first_type, last_type> equal_to;
34
35            typedef typename
36                boost::mpl::if_<
37                    equal_to
38                  , concat_type
39                  , boost::fusion::joint_view_iterator<first_type, last_type, concat_type>
40                >::type
41            type;
42
43            static type
44            call(Sequence& s);
45        };
46
47        template<typename Sequence>
48        typename begin_traits_impl<Sequence>::type
49        call(Sequence& s, boost::mpl::true_) {
50            return s.concat;
51        }
52
53        template<typename Sequence>
54        typename begin_traits_impl<Sequence>::type
55        call(Sequence& s, boost::mpl::false_) {
56            typedef BOOST_DEDUCED_TYPENAME begin_traits_impl<Sequence>::type type;
57            return type(s.first, s.concat);
58        }
59
60        template<typename Sequence>
61        typename begin_traits_impl<Sequence>::type
62        begin_traits_impl<Sequence>::call(Sequence& s)
63        {
64            return joint_view_detail::call(s, equal_to());
65        }
66
67        template <typename Sequence>
68        struct end_traits_impl
69        {
70            typedef typename Sequence::concat_last_type type;
71
72            static type
73            call(Sequence& s);
74        };
75
76        template<typename Sequence>
77        typename end_traits_impl<Sequence>::type
78        end_traits_impl<Sequence>::call(Sequence& s)
79        {
80            return s.concat_last;
81        }
82    }
83
84    namespace meta
85    {
86        template <typename Tag>
87        struct begin_impl;
88
89        template <>
90        struct begin_impl<joint_view_tag>
91        {
92            template <typename Sequence>
93            struct apply : joint_view_detail::begin_traits_impl<Sequence>
94            {};
95        };
96
97        template <typename Tag>
98        struct end_impl;
99
100        template <>
101        struct end_impl<joint_view_tag>
102        {
103            template <typename Sequence>
104            struct apply : joint_view_detail::end_traits_impl<Sequence>
105            {};
106        };
107    }
108}}
109
110namespace boost { namespace mpl
111{
112    template <typename Tag>
113    struct begin_impl;
114
115    template <typename Tag>
116    struct end_impl;
117
118    template <>
119    struct begin_impl<fusion::joint_view_tag>
120        : fusion::meta::begin_impl<fusion::joint_view_tag> {};
121
122    template <>
123    struct end_impl<fusion::joint_view_tag>
124        : fusion::meta::end_impl<fusion::joint_view_tag> {};
125}}
126
127#endif
128
129
Note: See TracBrowser for help on using the repository browser.