2 Copyright (c) Marshall Clow 2008-2012.
4 Distributed under the Boost Software License, Version 1.0. (See accompanying
5 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 For more information, see http://www.boost.org
11 /// \brief Test ranges to see if any elements match a value or predicate.
12 /// \author Marshall Clow
14 #ifndef BOOST_ALGORITHM_ANY_OF_HPP
15 #define BOOST_ALGORITHM_ANY_OF_HPP
17 #include <boost/range/begin.hpp>
18 #include <boost/range/end.hpp>
20 namespace boost { namespace algorithm {
22 /// \fn any_of ( InputIterator first, InputIterator last, Predicate p )
23 /// \return true if any of the elements in [first, last) satisfy the predicate
24 /// \note returns false on an empty range
26 /// \param first The start of the input sequence
27 /// \param last One past the end of the input sequence
28 /// \param p A predicate for testing the elements of the sequence
30 template<typename InputIterator, typename Predicate>
31 bool any_of ( InputIterator first, InputIterator last, Predicate p )
33 for ( ; first != last; ++first )
39 /// \fn any_of ( const Range &r, Predicate p )
40 /// \return true if any elements in the range satisfy the predicate 'p'
41 /// \note returns false on an empty range
43 /// \param r The input range
44 /// \param p A predicate for testing the elements of the range
46 template<typename Range, typename Predicate>
47 bool any_of ( const Range &r, Predicate p )
49 return boost::algorithm::any_of (boost::begin (r), boost::end (r), p);
52 /// \fn any_of_equal ( InputIterator first, InputIterator last, const V &val )
53 /// \return true if any of the elements in [first, last) are equal to 'val'
54 /// \note returns false on an empty range
56 /// \param first The start of the input sequence
57 /// \param last One past the end of the input sequence
58 /// \param val A value to compare against
60 template<typename InputIterator, typename V>
61 bool any_of_equal ( InputIterator first, InputIterator last, const V &val )
63 for ( ; first != last; ++first )
69 /// \fn any_of_equal ( const Range &r, const V &val )
70 /// \return true if any of the elements in the range are equal to 'val'
71 /// \note returns false on an empty range
73 /// \param r The input range
74 /// \param val A value to compare against
76 template<typename Range, typename V>
77 bool any_of_equal ( const Range &r, const V &val )
79 return boost::algorithm::any_of_equal (boost::begin (r), boost::end (r), val);
82 }} // namespace boost and algorithm
84 #endif // BOOST_ALGORITHM_ANY_OF_HPP