]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | /*============================================================================= |
2 | Copyright (c) 2001-2011 Joel de Guzman | |
3 | Copyright (c) 2006 Dan Marsden | |
4 | ||
5 | Distributed under the Boost Software License, Version 1.0. (See accompanying | |
6 | file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | |
7 | ==============================================================================*/ | |
8 | #if !defined(FUSION_BEGIN_IMPL_20060123_2147) | |
9 | #define FUSION_BEGIN_IMPL_20060123_2147 | |
10 | ||
11 | #include <boost/fusion/support/config.hpp> | |
12 | #include <boost/fusion/sequence/intrinsic/begin.hpp> | |
13 | #include <boost/fusion/view/zip_view/zip_view_iterator_fwd.hpp> | |
14 | #include <boost/fusion/algorithm/transformation/transform.hpp> | |
15 | #include <boost/type_traits/remove_reference.hpp> | |
16 | #include <boost/type_traits/is_reference.hpp> | |
17 | #include <boost/type_traits/is_same.hpp> | |
18 | #include <boost/mpl/assert.hpp> | |
19 | #include <boost/mpl/eval_if.hpp> | |
20 | #include <boost/mpl/identity.hpp> | |
21 | #include <boost/fusion/support/unused.hpp> | |
22 | ||
23 | namespace boost { namespace fusion { | |
24 | ||
25 | struct zip_view_tag; | |
26 | ||
27 | namespace detail | |
28 | { | |
29 | struct poly_begin | |
30 | { | |
31 | template<typename T> | |
32 | struct result; | |
33 | ||
34 | template<typename SeqRef> | |
35 | struct result<poly_begin(SeqRef)> | |
36 | : mpl::eval_if<is_same<SeqRef, unused_type const&>, | |
37 | mpl::identity<unused_type>, | |
38 | result_of::begin<typename remove_reference<SeqRef>::type> > | |
39 | { | |
40 | BOOST_MPL_ASSERT((is_reference<SeqRef>)); | |
41 | }; | |
42 | ||
43 | template<typename Seq> | |
44 | BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED | |
45 | typename result<poly_begin(Seq&)>::type | |
46 | operator()(Seq& seq) const | |
47 | { | |
48 | return fusion::begin(seq); | |
49 | } | |
50 | ||
51 | template<typename Seq> | |
52 | BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED | |
53 | typename result<poly_begin(Seq const&)>::type | |
54 | operator()(Seq const& seq) const | |
55 | { | |
56 | return fusion::begin(seq); | |
57 | } | |
58 | ||
59 | BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED | |
60 | unused_type operator()(unused_type const&) const | |
61 | { | |
62 | return unused_type(); | |
63 | } | |
64 | }; | |
65 | } | |
66 | ||
67 | namespace extension | |
68 | { | |
69 | template<typename Tag> | |
70 | struct begin_impl; | |
71 | ||
72 | template<> | |
73 | struct begin_impl<zip_view_tag> | |
74 | { | |
75 | template<typename Sequence> | |
76 | struct apply | |
77 | { | |
78 | typedef zip_view_iterator< | |
79 | typename result_of::transform<typename Sequence::sequences, detail::poly_begin>::type, | |
80 | typename Sequence::category> type; | |
81 | ||
82 | BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED | |
83 | static type | |
84 | call(Sequence& sequence) | |
85 | { | |
86 | return type( | |
87 | fusion::transform(sequence.sequences_, detail::poly_begin())); | |
88 | } | |
89 | }; | |
90 | ||
91 | ||
92 | ||
93 | }; | |
94 | } | |
95 | }} | |
96 | ||
97 | #endif |