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)
9 /// \brief Test ranges to see if no elements match a value or predicate.
10 /// \author Marshall Clow
12 #ifndef BOOST_ALGORITHM_NONE_OF_HPP
13 #define BOOST_ALGORITHM_NONE_OF_HPP
15 #include <boost/range/begin.hpp>
16 #include <boost/range/end.hpp>
18 namespace boost { namespace algorithm {
20 /// \fn none_of ( InputIterator first, InputIterator last, Predicate p )
21 /// \return true if none of the elements in [first, last) satisfy the predicate 'p'
22 /// \note returns true on an empty range
24 /// \param first The start of the input sequence
25 /// \param last One past the end of the input sequence
26 /// \param p A predicate for testing the elements of the sequence
28 template<typename InputIterator, typename Predicate>
29 bool none_of ( InputIterator first, InputIterator last, Predicate p )
31 for ( ; first != last; ++first )
37 /// \fn none_of ( const Range &r, Predicate p )
38 /// \return true if none of the elements in the range satisfy the predicate 'p'
39 /// \note returns true on an empty range
41 /// \param r The input range
42 /// \param p A predicate for testing the elements of the range
44 template<typename Range, typename Predicate>
45 bool none_of ( const Range &r, Predicate p )
47 return boost::algorithm::none_of (boost::begin (r), boost::end (r), p );
50 /// \fn none_of_equal ( InputIterator first, InputIterator last, const V &val )
51 /// \return true if none of the elements in [first, last) are equal to 'val'
52 /// \note returns true on an empty range
54 /// \param first The start of the input sequence
55 /// \param last One past the end of the input sequence
56 /// \param val A value to compare against
58 template<typename InputIterator, typename V>
59 bool none_of_equal ( InputIterator first, InputIterator last, const V &val )
61 for ( ; first != last; ++first )
67 /// \fn none_of_equal ( const Range &r, const V &val )
68 /// \return true if none of the elements in the range are equal to 'val'
69 /// \note returns true on an empty range
71 /// \param r The input range
72 /// \param val A value to compare against
74 template<typename Range, typename V>
75 bool none_of_equal ( const Range &r, const V & val )
77 return boost::algorithm::none_of_equal (boost::begin (r), boost::end (r), val);
80 }} // namespace boost and algorithm
82 #endif // BOOST_ALGORITHM_NONE_OF_HPP