annotate DEPENDENCIES/generic/include/boost/algorithm/cxx11/any_of.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents c530137014c0
children
rev   line source
Chris@16 1 /*
Chris@16 2 Copyright (c) Marshall Clow 2008-2012.
Chris@16 3
Chris@16 4 Distributed under the Boost Software License, Version 1.0. (See accompanying
Chris@16 5 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Chris@16 6
Chris@16 7 For more information, see http://www.boost.org
Chris@16 8 */
Chris@16 9
Chris@16 10 /// \file
Chris@16 11 /// \brief Test ranges to see if any elements match a value or predicate.
Chris@16 12 /// \author Marshall Clow
Chris@16 13
Chris@16 14 #ifndef BOOST_ALGORITHM_ANY_OF_HPP
Chris@16 15 #define BOOST_ALGORITHM_ANY_OF_HPP
Chris@16 16
Chris@16 17 #include <algorithm> // for std::any_of, if available
Chris@16 18 #include <boost/range/begin.hpp>
Chris@16 19 #include <boost/range/end.hpp>
Chris@16 20
Chris@16 21 namespace boost { namespace algorithm {
Chris@16 22
Chris@16 23 /// \fn any_of ( InputIterator first, InputIterator last, Predicate p )
Chris@16 24 /// \return true if any of the elements in [first, last) satisfy the predicate
Chris@16 25 /// \note returns false on an empty range
Chris@16 26 ///
Chris@16 27 /// \param first The start of the input sequence
Chris@16 28 /// \param last One past the end of the input sequence
Chris@16 29 /// \param p A predicate for testing the elements of the sequence
Chris@16 30 ///
Chris@16 31 template<typename InputIterator, typename Predicate>
Chris@16 32 bool any_of ( InputIterator first, InputIterator last, Predicate p )
Chris@16 33 {
Chris@16 34 for ( ; first != last; ++first )
Chris@16 35 if ( p(*first))
Chris@16 36 return true;
Chris@16 37 return false;
Chris@16 38 }
Chris@16 39
Chris@16 40 /// \fn any_of ( const Range &r, Predicate p )
Chris@16 41 /// \return true if any elements in the range satisfy the predicate 'p'
Chris@16 42 /// \note returns false on an empty range
Chris@16 43 ///
Chris@16 44 /// \param r The input range
Chris@16 45 /// \param p A predicate for testing the elements of the range
Chris@16 46 ///
Chris@16 47 template<typename Range, typename Predicate>
Chris@16 48 bool any_of ( const Range &r, Predicate p )
Chris@16 49 {
Chris@16 50 return boost::algorithm::any_of (boost::begin (r), boost::end (r), p);
Chris@16 51 }
Chris@16 52
Chris@16 53 /// \fn any_of_equal ( InputIterator first, InputIterator last, const V &val )
Chris@16 54 /// \return true if any of the elements in [first, last) are equal to 'val'
Chris@16 55 /// \note returns false on an empty range
Chris@16 56 ///
Chris@16 57 /// \param first The start of the input sequence
Chris@16 58 /// \param last One past the end of the input sequence
Chris@16 59 /// \param val A value to compare against
Chris@16 60 ///
Chris@16 61 template<typename InputIterator, typename V>
Chris@16 62 bool any_of_equal ( InputIterator first, InputIterator last, const V &val )
Chris@16 63 {
Chris@16 64 for ( ; first != last; ++first )
Chris@16 65 if ( val == *first )
Chris@16 66 return true;
Chris@16 67 return false;
Chris@16 68 }
Chris@16 69
Chris@16 70 /// \fn any_of_equal ( const Range &r, const V &val )
Chris@16 71 /// \return true if any of the elements in the range are equal to 'val'
Chris@16 72 /// \note returns false on an empty range
Chris@16 73 ///
Chris@16 74 /// \param r The input range
Chris@16 75 /// \param val A value to compare against
Chris@16 76 ///
Chris@16 77 template<typename Range, typename V>
Chris@16 78 bool any_of_equal ( const Range &r, const V &val )
Chris@16 79 {
Chris@16 80 return boost::algorithm::any_of_equal (boost::begin (r), boost::end (r), val);
Chris@16 81 }
Chris@16 82
Chris@16 83 }} // namespace boost and algorithm
Chris@16 84
Chris@16 85 #endif // BOOST_ALGORITHM_ANY_OF_HPP