]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/algorithm/include/boost/algorithm/cxx11/any_of.hpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / algorithm / include / boost / algorithm / cxx11 / any_of.hpp
1 /*
2 Copyright (c) Marshall Clow 2008-2012.
3
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)
6
7 For more information, see http://www.boost.org
8 */
9
10 /// \file
11 /// \brief Test ranges to see if any elements match a value or predicate.
12 /// \author Marshall Clow
13
14 #ifndef BOOST_ALGORITHM_ANY_OF_HPP
15 #define BOOST_ALGORITHM_ANY_OF_HPP
16
17 #include <boost/range/begin.hpp>
18 #include <boost/range/end.hpp>
19
20 namespace boost { namespace algorithm {
21
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
25 ///
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
29 ///
30 template<typename InputIterator, typename Predicate>
31 bool any_of ( InputIterator first, InputIterator last, Predicate p )
32 {
33 for ( ; first != last; ++first )
34 if ( p(*first))
35 return true;
36 return false;
37 }
38
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
42 ///
43 /// \param r The input range
44 /// \param p A predicate for testing the elements of the range
45 ///
46 template<typename Range, typename Predicate>
47 bool any_of ( const Range &r, Predicate p )
48 {
49 return boost::algorithm::any_of (boost::begin (r), boost::end (r), p);
50 }
51
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
55 ///
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
59 ///
60 template<typename InputIterator, typename V>
61 bool any_of_equal ( InputIterator first, InputIterator last, const V &val )
62 {
63 for ( ; first != last; ++first )
64 if ( val == *first )
65 return true;
66 return false;
67 }
68
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
72 ///
73 /// \param r The input range
74 /// \param val A value to compare against
75 ///
76 template<typename Range, typename V>
77 bool any_of_equal ( const Range &r, const V &val )
78 {
79 return boost::algorithm::any_of_equal (boost::begin (r), boost::end (r), val);
80 }
81
82 }} // namespace boost and algorithm
83
84 #endif // BOOST_ALGORITHM_ANY_OF_HPP