]>
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_DEREF_IMPL_20061024_1959) | |
9 | #define FUSION_DEREF_IMPL_20061024_1959 | |
10 | ||
11 | #include <boost/fusion/support/config.hpp> | |
12 | #include <boost/fusion/container/vector.hpp> | |
13 | #include <boost/fusion/iterator/deref.hpp> | |
14 | #include <boost/fusion/algorithm/transformation/transform.hpp> | |
15 | #include <boost/fusion/container/vector/convert.hpp> | |
16 | #include <boost/fusion/support/unused.hpp> | |
17 | #include <boost/mpl/eval_if.hpp> | |
18 | #include <boost/mpl/identity.hpp> | |
19 | #include <boost/type_traits/is_same.hpp> | |
20 | #include <boost/type_traits/remove_reference.hpp> | |
21 | #include <boost/type_traits/remove_const.hpp> | |
22 | ||
23 | namespace boost { namespace fusion { | |
24 | ||
25 | struct zip_view_iterator_tag; | |
26 | ||
27 | namespace detail | |
28 | { | |
29 | struct poly_deref | |
30 | { | |
31 | template<typename Sig> | |
32 | struct result; | |
33 | ||
34 | template<typename It> | |
35 | struct result<poly_deref(It)> | |
36 | { | |
37 | typedef typename remove_const< | |
38 | typename remove_reference<It>::type>::type it; | |
39 | ||
40 | typedef typename mpl::eval_if<is_same<it, unused_type>, | |
41 | mpl::identity<unused_type>, | |
42 | result_of::deref<it> >::type type; | |
43 | }; | |
44 | ||
45 | template<typename It> | |
46 | BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED | |
47 | typename result<poly_deref(It)>::type | |
48 | operator()(const It& it) const | |
49 | { | |
50 | return fusion::deref(it); | |
51 | } | |
52 | ||
53 | BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED | |
54 | unused_type operator()(unused_type const&) const | |
55 | { | |
56 | return unused_type(); | |
57 | } | |
58 | }; | |
59 | } | |
60 | ||
61 | namespace extension | |
62 | { | |
63 | template<typename Tag> | |
64 | struct deref_impl; | |
65 | ||
66 | template<> | |
67 | struct deref_impl<zip_view_iterator_tag> | |
68 | { | |
69 | template<typename It> | |
70 | struct apply | |
71 | { | |
72 | typedef typename result_of::as_vector< | |
73 | typename result_of::transform<typename It::iterators, detail::poly_deref>::type>::type type; | |
74 | ||
75 | BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED | |
76 | static type | |
77 | call(It const& it) | |
78 | { | |
79 | return type( | |
80 | fusion::transform(it.iterators_, detail::poly_deref())); | |
81 | } | |
82 | }; | |
83 | }; | |
84 | } | |
85 | }} | |
86 | ||
87 | #endif |