2006-08-16 16:50:52 +00:00
|
|
|
/*=============================================================================
|
|
|
|
Copyright (c) 2001-2006 Joel de Guzman
|
2011-08-18 17:12:05 +00:00
|
|
|
Copyright (c) 2011 Eric Niebler
|
2006-08-16 16:50:52 +00:00
|
|
|
|
2007-03-02 10:44:14 +00:00
|
|
|
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)
|
2006-08-16 16:50:52 +00:00
|
|
|
==============================================================================*/
|
|
|
|
#if !defined(FUSION_FIND_IF_05052005_1108)
|
|
|
|
#define FUSION_FIND_IF_05052005_1108
|
|
|
|
|
2011-08-18 17:12:05 +00:00
|
|
|
#include <boost/fusion/algorithm/query/find_if_fwd.hpp>
|
2006-08-16 16:50:52 +00:00
|
|
|
#include <boost/fusion/algorithm/query/detail/find_if.hpp>
|
2011-08-18 17:12:05 +00:00
|
|
|
#include <boost/fusion/algorithm/query/detail/segmented_find_if.hpp>
|
2009-10-25 22:59:54 +00:00
|
|
|
#include <boost/fusion/iterator/value_of.hpp>
|
2011-08-18 17:12:05 +00:00
|
|
|
#include <boost/fusion/support/is_segmented.hpp>
|
|
|
|
#include <boost/utility/enable_if.hpp>
|
|
|
|
#include <boost/type_traits/is_const.hpp>
|
2009-10-25 22:59:54 +00:00
|
|
|
#include <boost/mpl/bind.hpp>
|
|
|
|
#include <boost/mpl/lambda.hpp>
|
2011-08-18 17:12:05 +00:00
|
|
|
#include <boost/mpl/placeholders.hpp>
|
2009-10-25 22:59:54 +00:00
|
|
|
#include <boost/mpl/quote.hpp>
|
2006-08-16 16:50:52 +00:00
|
|
|
|
|
|
|
namespace boost { namespace fusion
|
|
|
|
{
|
|
|
|
namespace result_of
|
|
|
|
{
|
|
|
|
template <typename Sequence, typename Pred>
|
|
|
|
struct find_if
|
2011-08-18 17:12:05 +00:00
|
|
|
: mpl::if_<
|
|
|
|
traits::is_segmented<Sequence>
|
|
|
|
, detail::result_of_segmented_find_if<Sequence, Pred>
|
|
|
|
, detail::result_of_find_if<
|
|
|
|
Sequence,
|
|
|
|
mpl::bind1<
|
2009-10-25 22:59:54 +00:00
|
|
|
typename mpl::lambda<Pred>::type
|
2011-08-18 17:12:05 +00:00
|
|
|
, mpl::bind1<mpl::quote1<value_of>, mpl::_1>
|
2009-10-25 22:59:54 +00:00
|
|
|
>
|
|
|
|
>
|
2011-08-18 17:12:05 +00:00
|
|
|
>::type
|
|
|
|
{};
|
2006-08-16 16:50:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
template <typename Pred, typename Sequence>
|
|
|
|
inline typename
|
|
|
|
lazy_disable_if<
|
|
|
|
is_const<Sequence>
|
|
|
|
, result_of::find_if<Sequence, Pred>
|
|
|
|
>::type
|
|
|
|
find_if(Sequence& seq)
|
|
|
|
{
|
2009-10-25 22:59:54 +00:00
|
|
|
typedef typename result_of::find_if<Sequence, Pred>::filter filter;
|
2011-08-18 17:12:05 +00:00
|
|
|
return filter::call(seq);
|
2006-08-16 16:50:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
template <typename Pred, typename Sequence>
|
2006-11-09 01:48:46 +00:00
|
|
|
inline typename result_of::find_if<Sequence const, Pred>::type const
|
2006-08-16 16:50:52 +00:00
|
|
|
find_if(Sequence const& seq)
|
|
|
|
{
|
2009-10-30 15:14:50 +00:00
|
|
|
typedef typename result_of::find_if<Sequence const, Pred>::filter filter;
|
2011-08-18 17:12:05 +00:00
|
|
|
return filter::call(seq);
|
2006-08-16 16:50:52 +00:00
|
|
|
}
|
|
|
|
}}
|
|
|
|
|
|
|
|
#endif
|