find_if.hpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #ifndef BOOST_MPL_FIND_IF_HPP_INCLUDED
  2. #define BOOST_MPL_FIND_IF_HPP_INCLUDED
  3. // Copyright Aleksey Gurtovoy 2000-2004
  4. //
  5. // Distributed under the Boost Software License, Version 1.0.
  6. // (See accompanying file LICENSE_1_0.txt or copy at
  7. // http://www.boost.org/LICENSE_1_0.txt)
  8. //
  9. // See http://www.boost.org/libs/mpl for documentation.
  10. // $Id$
  11. // $Date$
  12. // $Revision$
  13. #include <boost/mpl/aux_/find_if_pred.hpp>
  14. #include <boost/mpl/arg.hpp>
  15. #include <boost/mpl/iter_fold_if.hpp>
  16. #include <boost/mpl/aux_/common_name_wknd.hpp>
  17. #include <boost/mpl/aux_/na_spec.hpp>
  18. #include <boost/mpl/aux_/lambda_support.hpp>
  19. namespace boost { namespace mpl {
  20. BOOST_MPL_AUX_COMMON_NAME_WKND(find_if)
  21. template<
  22. typename BOOST_MPL_AUX_NA_PARAM(Sequence)
  23. , typename BOOST_MPL_AUX_NA_PARAM(Predicate)
  24. >
  25. struct find_if
  26. {
  27. typedef typename iter_fold_if<
  28. Sequence
  29. , void
  30. , mpl::arg<1> // ignore
  31. , protect< aux::find_if_pred<Predicate> >
  32. >::type result_;
  33. typedef typename second<result_>::type type;
  34. BOOST_MPL_AUX_LAMBDA_SUPPORT(2,find_if,(Sequence,Predicate))
  35. };
  36. BOOST_MPL_AUX_NA_SPEC(2,find_if)
  37. }}
  38. #endif // BOOST_MPL_FIND_IF_HPP_INCLUDED