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/config.hpp>
18 #include <boost/range/begin.hpp>
19 #include <boost/range/end.hpp>
21 namespace boost { namespace algorithm {
23 /// \fn any_of ( InputIterator first, InputIterator last, Predicate p )
24 /// \return true if any of the elements in [first, last) satisfy the predicate
25 /// \note returns false on an empty range
27 /// \param first The start of the input sequence
28 /// \param last One past the end of the input sequence
29 /// \param p A predicate for testing the elements of the sequence
31 template<typename InputIterator, typename Predicate>
32 BOOST_CXX14_CONSTEXPR bool any_of ( InputIterator first, InputIterator last, Predicate p )
34 for ( ; first != last; ++first )
40 /// \fn any_of ( const Range &r, Predicate p )
41 /// \return true if any elements in the range satisfy the predicate 'p'
42 /// \note returns false on an empty range
44 /// \param r The input range
45 /// \param p A predicate for testing the elements of the range
47 template<typename Range, typename Predicate>
48 BOOST_CXX14_CONSTEXPR bool any_of ( const Range &r, Predicate p )
50 return boost::algorithm::any_of (boost::begin (r), boost::end (r), p);
53 /// \fn any_of_equal ( InputIterator first, InputIterator last, const V &val )
54 /// \return true if any of the elements in [first, last) are equal to 'val'
55 /// \note returns false on an empty range
57 /// \param first The start of the input sequence
58 /// \param last One past the end of the input sequence
59 /// \param val A value to compare against
61 template<typename InputIterator, typename V>
62 BOOST_CXX14_CONSTEXPR bool any_of_equal ( InputIterator first, InputIterator last, const V &val )
64 for ( ; first != last; ++first )
70 /// \fn any_of_equal ( const Range &r, const V &val )
71 /// \return true if any of the elements in the range are equal to 'val'
72 /// \note returns false on an empty range
74 /// \param r The input range
75 /// \param val A value to compare against
77 template<typename Range, typename V>
78 BOOST_CXX14_CONSTEXPR bool any_of_equal ( const Range &r, const V &val )
80 return boost::algorithm::any_of_equal (boost::begin (r), boost::end (r), val);
83 }} // namespace boost and algorithm
85 #endif // BOOST_ALGORITHM_ANY_OF_HPP