1[/ File find_not.qbk] 2 3[section:find_not find_not ] 4 5[/license 6Copyright (c) 2018 T. Zachary Laine 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 'find_not.hpp' contains a variants of a the stl algorithm 13`find`. The algorithm finds the first value in the given sequence that is not 14equal to the given value. 15 16Consider this use of `find()`: 17 18 std::vector<int> vec = { 1, 1, 2 }; 19 auto it = std::find(vec.begin(), vec.end(), 1); 20 21This gives us the first occurance of `1` in `vec`. What if we want to find 22the first occurrance of any number besides `1` in `vec`? We have to write an 23unfortunate amount of code: 24 25 std::vector<int> vec = { 1, 1, 2 }; 26 auto it = std::find_if(vec.begin(), vec.end(), [](int i) { return i != 1; }); 27 28With `find_not()` the code gets much more terse: 29 30 std::vector<int> vec = { 1, 1, 2 }; 31 auto it = find_not(vec.begin(), vec.end(), 1); 32 33The existing `find` variants are: `find()`, `find_if()`, and `find_if_not()`. 34It seems natural to also have `find_not()`, for the very reason that we have 35`find_if_not()` -- to avoid having to write a lambda to wrap the negation of 36the find condition. 37 38[heading interface] 39 40 template<typename InputIter, typename Sentinel, typename T> 41 InputIter find_not(InputIter first, Sentinel last, const T & x); 42 43 template<typename Range, typename T> 44 boost::range_iterator<Range> find_not(Range & r, const T & x); 45 46These overloads of `find_not` return the first value that is not equal to `x` 47in the sequence `[first, last)` or `r`, respectively. 48 49[heading Examples] 50 51Given the container `c1` containing `{ 0, 1, 2 }`, then 52 53 find_not ( c1.begin(), c1.end(), 1 ) --> c1.begin() 54 find_not ( c1.begin(), c1.end(), 0 ) --> std::next(c1.begin()) 55 56[heading Iterator Requirements] 57 58`find_not` works on all iterators except output iterators. 59 60The template parameter `Sentinel` is allowed to be different from `InputIter`, 61or they may be the same. For an `InputIter` `it` and a `Sentinel` `end`, `it 62== end` and `it != end` must be well-formed expressions. 63 64[heading Complexity] 65 66Linear. 67 68[heading Exception Safety] 69 70`find_not` takes its parameters by value and do not depend upon any global 71state. Therefore, it provides the strong exception guarantee. 72 73[heading Notes] 74 75`constexpr` in C++14 or later. 76 77[endsect] 78 79[/ File equal.qbk 80Copyright 2018 T. Zachary Laine 81Distributed under the Boost Software License, Version 1.0. 82(See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt). 83] 84