Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:31:09

0001 /*=============================================================================
0002     Copyright (c) 2001-2011 Joel de Guzman
0003     Copyright (c) 2007 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_ALL_05052005_1237)
0009 #define FUSION_ALL_05052005_1237
0010 
0011 #include <boost/fusion/support/config.hpp>
0012 #include <boost/mpl/bool.hpp>
0013 #include <boost/fusion/sequence/intrinsic/begin.hpp>
0014 #include <boost/fusion/sequence/intrinsic/end.hpp>
0015 #include <boost/fusion/iterator/advance.hpp>
0016 #include <boost/fusion/iterator/equal_to.hpp>
0017 #include <boost/fusion/iterator/next.hpp>
0018 #include <boost/fusion/iterator/deref.hpp>
0019 #include <boost/fusion/iterator/distance.hpp>
0020 
0021 namespace boost { namespace fusion { namespace detail
0022 {
0023     template <typename First, typename Last, typename F>
0024     BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0025     inline bool
0026     linear_all(First const&, Last const&, F const&, mpl::true_)
0027     {
0028         return true;
0029     }
0030 
0031     template <typename First, typename Last, typename F>
0032     BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0033     inline bool
0034     linear_all(First const& first, Last const& last, F& f, mpl::false_)
0035     {
0036         typename result_of::deref<First>::type x = *first;
0037         return f(x) &&
0038             detail::linear_all(
0039                 fusion::next(first)
0040               , last
0041               , f
0042               , result_of::equal_to<typename result_of::next<First>::type, Last>());
0043     }
0044 
0045     template <typename Sequence, typename F, typename Tag>
0046     BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0047     inline bool
0048     all(Sequence const& seq, F f, Tag)
0049     {
0050         return detail::linear_all(
0051                 fusion::begin(seq)
0052               , fusion::end(seq)
0053               , f
0054               , result_of::equal_to<
0055                     typename result_of::begin<Sequence>::type
0056                   , typename result_of::end<Sequence>::type>());
0057     }
0058 
0059     template<int N>
0060     struct unrolled_all
0061     {
0062         template <typename It, typename F>
0063         BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0064         static bool call(It const& it, F f)
0065         {
0066             return
0067                 f(*it) &&
0068                 f(*fusion::advance_c<1>(it))&&
0069                 f(*fusion::advance_c<2>(it)) &&
0070                 f(*fusion::advance_c<3>(it)) &&
0071                 detail::unrolled_all<N-4>::call(fusion::advance_c<4>(it), f);
0072         }
0073     };
0074 
0075     template<>
0076     struct unrolled_all<3>
0077     {
0078         template <typename It, typename F>
0079         BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0080         static bool call(It const& it, F f)
0081         {
0082             return
0083                 f(*it) &&
0084                 f(*fusion::advance_c<1>(it)) &&
0085                 f(*fusion::advance_c<2>(it));
0086         }
0087     };
0088 
0089     template<>
0090     struct unrolled_all<2>
0091     {
0092         template <typename It, typename F>
0093         BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0094         static bool call(It const& it, F f)
0095         {
0096             return
0097                 f(*it) &&
0098                 f(*fusion::advance_c<1>(it));
0099         }
0100     };
0101 
0102     template<>
0103     struct unrolled_all<1>
0104     {
0105         template <typename It, typename F>
0106         BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0107         static bool call(It const& it, F f)
0108         {
0109             return f(*it);
0110         }
0111     };
0112 
0113     template<>
0114     struct unrolled_all<0>
0115     {
0116         template <typename It, typename F>
0117         BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0118         static bool call(It const& /*it*/, F /*f*/)
0119         {
0120             return true;
0121         }
0122     };
0123 
0124     template <typename Sequence, typename F>
0125     BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0126     inline bool
0127     all(Sequence const& seq, F f, random_access_traversal_tag)
0128     {
0129         typedef typename result_of::begin<Sequence>::type begin;
0130         typedef typename result_of::end<Sequence>::type end;
0131         return detail::unrolled_all<result_of::distance<begin, end>::type::value>::call(
0132             fusion::begin(seq), f);
0133     }
0134 }}}
0135 
0136 #endif
0137