1[/ File none_of.qbk] 2 3[section:none_of none_of] 4 5[/license 6Copyright (c) 2010-2012 Marshall Clow 7 8Distributed under the Boost Software License, Version 1.0. 9(See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 10] 11 12The header file 'boost/algorithm/cxx11/none_of.hpp' contains four variants of a single algorithm, `none_of`. The algorithm tests all the elements of a sequence and returns true if they none of them share a property. 13 14The routine `none_of` takes a sequence and a predicate. It will return true if the predicate returns false when applied to every element in the sequence. 15 16The routine `none_of_equal` takes a sequence and a value. It will return true if none of the elements in the sequence compare equal to the passed in value. 17 18Both routines come in two forms; the first one takes two iterators to define the range. The second form takes a single range parameter, and uses Boost.Range to traverse it. 19 20 21[heading interface] 22 23The function `none_of` returns true if the predicate returns false for every item in the sequence. There are two versions; one takes two iterators, and the other takes a range. 24 25`` 26namespace boost { namespace algorithm { 27template<typename InputIterator, typename Predicate> 28 bool none_of ( InputIterator first, InputIterator last, Predicate p ); 29template<typename Range, typename Predicate> 30 bool none_of ( const Range &r, Predicate p ); 31}} 32`` 33 34The function `none_of_equal` is similar to `none_of`, but instead of taking a predicate to test the elements of the sequence, it takes a value to compare against. 35 36`` 37namespace boost { namespace algorithm { 38template<typename InputIterator, typename V> 39 bool none_of_equal ( InputIterator first, InputIterator last, V const &val ); 40template<typename Range, typename V> 41 bool none_of_equal ( const Range &r, V const &val ); 42}} 43`` 44 45[heading Examples] 46 47Given the container `c` containing `{ 0, 1, 2, 3, 14, 15 }`, then 48`` 49bool isOdd ( int i ) { return i % 2 == 1; } 50bool lessThan10 ( int i ) { return i < 10; } 51 52using boost::algorithm; 53 54none_of ( c, isOdd ) --> false 55none_of ( c.begin (), c.end (), lessThan10 ) --> false 56none_of ( c.begin () + 4, c.end (), lessThan10 ) --> true 57none_of ( c.end (), c.end (), isOdd ) --> true // empty range 58none_of_equal ( c, 3 ) --> false 59none_of_equal ( c.begin (), c.begin () + 3, 3 ) --> true 60none_of_equal ( c.begin (), c.begin (), 99 ) --> true // empty range 61`` 62 63[heading Iterator Requirements] 64 65`none_of` and `none_of_equal` work on all iterators except output iterators. 66 67[heading Complexity] 68 69All of the variants of `none_of` and `none_of_equal` run in ['O(N)] (linear) time; that is, they compare against each element in the list once. If any of the comparisons succeed, the algorithm will terminate immediately, without examining the remaining members of the sequence. 70 71[heading Exception Safety] 72 73All of the variants of `none_of` and `none_of_equal` take their parameters by value or const reference, and do not depend upon any global state. Therefore, all the routines in this file provide the strong exception guarantee. 74 75[heading Notes] 76 77* The routine `none_of` is also available as part of the C++11 standard. 78 79* `none_of` and `none_of_equal` both return true for empty ranges, no matter what is passed to test against. 80 81* The second parameter to `none_of_value` is a template parameter, rather than deduced from the first parameter (`std::iterator_traits<InputIterator>::value_type`) because that allows more flexibility for callers, and takes advantage of built-in comparisons for the type that is pointed to by the iterator. The function is defined to return true if, for all elements in the sequence, the expression `*iter == val` evaluates to false (where `iter` is an iterator to each element in the sequence) 82 83[endsect] 84 85[/ File none_of.qbk 86Copyright 2011 Marshall Clow 87Distributed under the Boost Software License, Version 1.0. 88(See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt). 89] 90 91