Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-27 09:36:41

0001 /*=============================================================================
0002     Copyright (c) 2001-2011 Joel de Guzman
0003     Copyright (c) 2006 Dan Marsden
0004 
0005     Distributed under the Boost Software License, Version 1.0. (See accompanying 
0006     file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0007 ==============================================================================*/
0008 #if !defined(FUSION_END_IMPL_20060123_2208)
0009 #define FUSION_END_IMPL_20060123_2208
0010 
0011 #include <boost/fusion/support/config.hpp>
0012 #include <boost/fusion/view/zip_view/zip_view_iterator_fwd.hpp>
0013 #include <boost/fusion/sequence/intrinsic/end.hpp>
0014 #include <boost/fusion/sequence/intrinsic/begin.hpp>
0015 #include <boost/fusion/sequence/intrinsic/size.hpp>
0016 #include <boost/fusion/sequence/intrinsic/front.hpp>
0017 #include <boost/fusion/iterator/advance.hpp>
0018 #include <boost/fusion/algorithm/transformation/transform.hpp>
0019 #include <boost/type_traits/remove_reference.hpp>
0020 #include <boost/type_traits/is_reference.hpp>
0021 #include <boost/mpl/assert.hpp>
0022 #include <boost/mpl/min.hpp>
0023 
0024 #include <boost/mpl/eval_if.hpp>
0025 #include <boost/mpl/identity.hpp>
0026 #include <boost/type_traits/is_same.hpp>
0027 
0028 namespace boost { namespace fusion {
0029 
0030     struct zip_view_tag;
0031 
0032     namespace detail
0033     {
0034         template<typename SeqRef, typename M>
0035         struct get_endpoint
0036         {
0037             typedef typename remove_reference<SeqRef>::type Seq;
0038             typedef typename result_of::begin<Seq>::type begin;
0039             typedef typename result_of::advance<begin, M>::type type;            
0040         };
0041 
0042         template<typename M>
0043         struct endpoints
0044         {
0045             template<typename T>
0046             struct result;
0047 
0048             template<typename M1, typename SeqRef>
0049             struct result<endpoints<M1>(SeqRef)>
0050                 : mpl::eval_if<is_same<SeqRef, unused_type const&>,
0051                                mpl::identity<unused_type>,
0052                                get_endpoint<SeqRef, M> >
0053             {
0054                 BOOST_MPL_ASSERT((is_reference<SeqRef>));
0055             };
0056 
0057             template<typename Seq>
0058             BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0059             typename result<endpoints(Seq&)>::type
0060             operator()(Seq& seq) const
0061             {
0062                 return fusion::advance<M>(fusion::begin(seq));
0063             }
0064 
0065             template<typename Seq>
0066             BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0067             typename result<endpoints(Seq const&)>::type
0068             operator()(Seq const& seq) const
0069             {
0070                 return fusion::advance<M>(fusion::begin(seq));
0071             }
0072 
0073             BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0074             unused_type operator()(unused_type const&) const
0075             {
0076                 return unused_type();
0077             }
0078         };
0079     }
0080 
0081     namespace extension
0082     {
0083         template<typename Tag>
0084         struct end_impl;
0085 
0086         template<>
0087         struct end_impl<zip_view_tag>
0088         {
0089             template<typename Sequence>
0090             struct apply
0091             {
0092                 typedef zip_view_iterator<
0093                     typename result_of::transform<typename Sequence::sequences, detail::endpoints<typename Sequence::size> >::type,
0094                     typename Sequence::category> type;
0095 
0096                 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0097                 static type
0098                 call(Sequence& sequence)
0099                 {
0100                     return type(
0101                         fusion::transform(sequence.sequences_, detail::endpoints<typename Sequence::size>()));
0102                 }
0103             };
0104         };
0105     }
0106 }}
0107 
0108 #endif