/*============================================================================= Copyright (c) 2003 Joel de Guzman Copyright (c) 2004 Peder Holt Use, modification and distribution is subject to 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_ALGORITHM_DETAIL_FIND_IF_HPP) #define FUSION_ALGORITHM_DETAIL_FIND_IF_HPP #include #include #include #include #include #include #include namespace boost { namespace fusion { namespace detail { template struct apply_filter { typedef typename mpl::apply1< Pred , typename meta::value_of::type >::type type; }; template struct main_find_if; template struct recursive_find_if { typedef typename main_find_if< typename meta::next::type, Last, Pred >::type type; }; template struct main_find_if { typedef mpl::or_< meta::equal_to , apply_filter > filter; typedef typename mpl::eval_if< filter , mpl::identity , recursive_find_if >::type type; }; template struct static_find_if; namespace static_find_if_detail { template typename main_find_if::type>::type call(static_find_if const& obj,Iterator const& iter); } template struct static_find_if { typedef typename main_find_if< First , Last , typename mpl::lambda::type >::type type; //Workaround to please MSVC template static type call(Iterator const& iter) { return static_find_if_detail::call(static_find_if(),iter); } }; namespace static_find_if_detail { template typename static_find_if::type call(static_find_if const&, Iterator const& iter, mpl::true_) { return iter; }; template typename static_find_if::type call(static_find_if const& obj,Iterator const& iter, mpl::false_) { return call(obj,fusion::next(iter)); }; template typename main_find_if::type>::type call(static_find_if const& obj,Iterator const& iter) { typedef meta::equal_to::type> found; return call(obj,iter, found()); }; } }}} #endif