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/config.hpp>
16 #include <boost/range/begin.hpp>
17 #include <boost/range/end.hpp>
19 namespace boost { namespace algorithm {
21 /// \fn none_of ( InputIterator first, InputIterator last, Predicate p )
22 /// \return true if none of the elements in [first, last) satisfy the predicate 'p'
23 /// \note returns true on an empty range
25 /// \param first The start of the input sequence
26 /// \param last One past the end of the input sequence
27 /// \param p A predicate for testing the elements of the sequence
29 template<typename InputIterator, typename Predicate>
30 BOOST_CXX14_CONSTEXPR bool none_of ( InputIterator first, InputIterator last, Predicate p )
32 for ( ; first != last; ++first )
38 /// \fn none_of ( const Range &r, Predicate p )
39 /// \return true if none of the elements in the range satisfy the predicate 'p'
40 /// \note returns true on an empty range
42 /// \param r The input range
43 /// \param p A predicate for testing the elements of the range
45 template<typename Range, typename Predicate>
46 BOOST_CXX14_CONSTEXPR bool none_of ( const Range &r, Predicate p )
48 return boost::algorithm::none_of (boost::begin (r), boost::end (r), p );
51 /// \fn none_of_equal ( InputIterator first, InputIterator last, const V &val )
52 /// \return true if none of the elements in [first, last) are equal to 'val'
53 /// \note returns true on an empty range
55 /// \param first The start of the input sequence
56 /// \param last One past the end of the input sequence
57 /// \param val A value to compare against
59 template<typename InputIterator, typename V>
60 BOOST_CXX14_CONSTEXPR bool none_of_equal ( InputIterator first, InputIterator last, const V &val )
62 for ( ; first != last; ++first )
68 /// \fn none_of_equal ( const Range &r, const V &val )
69 /// \return true if none of the elements in the range are equal to 'val'
70 /// \note returns true on an empty range
72 /// \param r The input range
73 /// \param val A value to compare against
75 template<typename Range, typename V>
76 BOOST_CXX14_CONSTEXPR bool none_of_equal ( const Range &r, const V & val )
78 return boost::algorithm::none_of_equal (boost::begin (r), boost::end (r), val);
81 }} // namespace boost and algorithm
83 #endif // BOOST_ALGORITHM_NONE_OF_HPP