annotate DEPENDENCIES/generic/include/boost/algorithm/cxx11/any_of.hpp @ 92:1abd36a8d5b8

Another absolute path
author Chris Cannam
date Tue, 14 Apr 2015 16:53:26 +0100
parents 2665513ce2d3
children c530137014c0
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 // Use the C++11 versions of any_of if it is available
Chris@16 24 #if __cplusplus >= 201103L
Chris@16 25 using std::any_of; // Section 25.2.2
Chris@16 26 #else
Chris@16 27 /// \fn any_of ( InputIterator first, InputIterator last, Predicate p )
Chris@16 28 /// \return true if any of the elements in [first, last) satisfy the predicate
Chris@16 29 /// \note returns false on an empty range
Chris@16 30 ///
Chris@16 31 /// \param first The start of the input sequence
Chris@16 32 /// \param last One past the end of the input sequence
Chris@16 33 /// \param p A predicate for testing the elements of the sequence
Chris@16 34 ///
Chris@16 35 template<typename InputIterator, typename Predicate>
Chris@16 36 bool any_of ( InputIterator first, InputIterator last, Predicate p )
Chris@16 37 {
Chris@16 38 for ( ; first != last; ++first )
Chris@16 39 if ( p(*first))
Chris@16 40 return true;
Chris@16 41 return false;
Chris@16 42 }
Chris@16 43 #endif
Chris@16 44
Chris@16 45 /// \fn any_of ( const Range &r, Predicate p )
Chris@16 46 /// \return true if any elements in the range satisfy the predicate 'p'
Chris@16 47 /// \note returns false on an empty range
Chris@16 48 ///
Chris@16 49 /// \param r The input range
Chris@16 50 /// \param p A predicate for testing the elements of the range
Chris@16 51 ///
Chris@16 52 template<typename Range, typename Predicate>
Chris@16 53 bool any_of ( const Range &r, Predicate p )
Chris@16 54 {
Chris@16 55 return boost::algorithm::any_of (boost::begin (r), boost::end (r), p);
Chris@16 56 }
Chris@16 57
Chris@16 58 /// \fn any_of_equal ( InputIterator first, InputIterator last, const V &val )
Chris@16 59 /// \return true if any of the elements in [first, last) are equal to 'val'
Chris@16 60 /// \note returns false on an empty range
Chris@16 61 ///
Chris@16 62 /// \param first The start of the input sequence
Chris@16 63 /// \param last One past the end of the input sequence
Chris@16 64 /// \param val A value to compare against
Chris@16 65 ///
Chris@16 66 template<typename InputIterator, typename V>
Chris@16 67 bool any_of_equal ( InputIterator first, InputIterator last, const V &val )
Chris@16 68 {
Chris@16 69 for ( ; first != last; ++first )
Chris@16 70 if ( val == *first )
Chris@16 71 return true;
Chris@16 72 return false;
Chris@16 73 }
Chris@16 74
Chris@16 75 /// \fn any_of_equal ( const Range &r, const V &val )
Chris@16 76 /// \return true if any of the elements in the range are equal to 'val'
Chris@16 77 /// \note returns false on an empty range
Chris@16 78 ///
Chris@16 79 /// \param r The input range
Chris@16 80 /// \param val A value to compare against
Chris@16 81 ///
Chris@16 82 template<typename Range, typename V>
Chris@16 83 bool any_of_equal ( const Range &r, const V &val )
Chris@16 84 {
Chris@16 85 return boost::algorithm::any_of_equal (boost::begin (r), boost::end (r), val);
Chris@16 86 }
Chris@16 87
Chris@16 88 }} // namespace boost and algorithm
Chris@16 89
Chris@16 90 #endif // BOOST_ALGORITHM_ANY_OF_HPP