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