/*============================================================================= Copyright (c) 2001-2011 Joel de Guzman Copyright (c) 2005 Eric Niebler Copyright (c) 2007 Dan Marsden Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ==============================================================================*/ #if !defined(FUSION_ANY_05052005_1229) #define FUSION_ANY_05052005_1229 #include #include #include #include #include #include #include #include #include namespace boost { namespace fusion { struct random_access_traversal_tag; namespace detail { template BOOST_FUSION_GPU_ENABLED inline bool linear_any(First const&, Last const&, F const&, mpl::true_) { return false; } template BOOST_FUSION_GPU_ENABLED inline bool linear_any(First const& first, Last const& last, F& f, mpl::false_) { typename result_of::deref::type x = *first; return f(x) || detail::linear_any( fusion::next(first) , last , f , result_of::equal_to::type, Last>()); } template BOOST_FUSION_GPU_ENABLED inline bool any(Sequence const& seq, F f, Tag) { return detail::linear_any( fusion::begin(seq) , fusion::end(seq) , f , result_of::equal_to< typename result_of::begin::type , typename result_of::end::type>()); } template struct unrolled_any { template BOOST_FUSION_GPU_ENABLED static bool call(It const& it, F f) { return f(*it) || f(*fusion::advance_c<1>(it))|| f(*fusion::advance_c<2>(it)) || f(*fusion::advance_c<3>(it)) || detail::unrolled_any::call(fusion::advance_c<4>(it), f); } }; template<> struct unrolled_any<3> { template BOOST_FUSION_GPU_ENABLED static bool call(It const& it, F f) { return f(*it) || f(*fusion::advance_c<1>(it)) || f(*fusion::advance_c<2>(it)); } }; template<> struct unrolled_any<2> { template BOOST_FUSION_GPU_ENABLED static bool call(It const& it, F f) { return f(*it) || f(*fusion::advance_c<1>(it)); } }; template<> struct unrolled_any<1> { template BOOST_FUSION_GPU_ENABLED static bool call(It const& it, F f) { return f(*it); } }; template<> struct unrolled_any<0> { template BOOST_FUSION_GPU_ENABLED static bool call(It const&, F) { return false; } }; template BOOST_FUSION_GPU_ENABLED inline bool any(Sequence const& seq, F f, random_access_traversal_tag) { typedef typename result_of::begin::type begin; typedef typename result_of::end::type end; return detail::unrolled_any::type::value>::call( fusion::begin(seq), f); } }}} #endif