From 6b2246468e7ac1cca396cbf3e1f2dbb4529e0527 Mon Sep 17 00:00:00 2001 From: Zach Laine Date: Sat, 12 May 2018 16:47:47 -0500 Subject: [PATCH] find_{not,*backward} docs copy editing. --- doc/find_backward.qbk | 39 ++++++++++++++++++++------------------- doc/find_not.qbk | 16 +++++++--------- 2 files changed, 27 insertions(+), 28 deletions(-) diff --git a/doc/find_backward.qbk b/doc/find_backward.qbk index 81cec0c..838dbc9 100644 --- a/doc/find_backward.qbk +++ b/doc/find_backward.qbk @@ -11,7 +11,7 @@ Distributed under the Boost Software License, Version 1.0. The header file 'find_backward.hpp' contains variants of the stl algorithm `find`. These variants are like `find`, except that the evaluate the elements -of the given sequence if reverse order. +of the given sequence in reverse order. Consider how finding the last element that is equal to `x` in a range is typically done: @@ -23,7 +23,7 @@ typically done: } } -Raw loops are icky though. PErhaps we should do a bit of extra work to allow +Raw loops are icky though. Perhaps we should do a bit of extra work to allow the use of `std::find()`: auto rfirst = std::make_reverse_iterator(last); @@ -31,31 +31,31 @@ the use of `std::find()`: auto it = std::find(rfirst, rlast); // Use it here... -That seems nicer, but it has two major drawbacks. First, it requires an -unpleasant amount of typing. Second, it is considerably less efficient than -forward-iterator `find` , since `std::reverse_iterator` calls its -base-iterator's `operator--()` in most of its members before doing the work -that the member requires. +That seems nicer in that there is no raw loop, but it has two major drawbacks. +First, it requires an unpleasant amount of typing. Second, it is less +efficient than forward-iterator `find` , since `std::reverse_iterator` calls +its base-iterator's `operator--()` in most of its member functions before +doing the work that the member function requires. [heading interface] template - BidiIter find_backward(BidiIter first, BidiIter last, T const & x); + BidiIter find_backward(BidiIter first, BidiIter last, const T & x); template - boost::range_iterator find_backward(Range & range, T const & x); + boost::range_iterator find_backward(Range & range, const T & x); -The function `find_backward` returns an iterator to the last element that is -equal to `x` in `[first, last)` or `r`, respectively. +These overloads of `find_backward` return an iterator to the last element that +is equal to `x` in `[first, last)` or `r`, respectively. template - BidiIter find_not_backward(BidiIter first, BidiIter last, T const & x); + BidiIter find_not_backward(BidiIter first, BidiIter last, const T & x); template - boost::range_iterator find_not_backward(Range & range, T const & x); + boost::range_iterator find_not_backward(Range & range, const T & x); -The function `find_not_backward` returns an iterator to the last element that -is not equal to `x` in `[first, last)` or `r`, respectively. +These overloads of `find_not_backward` return an iterator to the last element +that is not equal to `x` in `[first, last)` or `r`, respectively. template BidiIter find_if_backward(BidiIter first, BidiIter last, Pred p); @@ -63,8 +63,8 @@ is not equal to `x` in `[first, last)` or `r`, respectively. template boost::range_iterator find_if_backward(Range & range, Pred p); -The function `find_if_backward` returns an iterator to the last element for -which `pred` returns `true` in `[first, last)` or `r`, respectively. +These overloads of `find_if_backward` return an iterator to the last element +for which `pred` returns `true` in `[first, last)` or `r`, respectively. template BidiIter find_if_not_backward(BidiIter first, BidiIter last, Pred p); @@ -72,8 +72,9 @@ which `pred` returns `true` in `[first, last)` or `r`, respectively. template boost::range_iterator find_if_not_backward(Range & range, Pred p); -The function `find_if_not_backward` returns an iterator to the last element -for which `pred` returns `false` in `[first, last)` or `r`, respectively. +These overloads of `find_if_not_backward` return an iterator to the last +element for which `pred` returns `false` in `[first, last)` or `r`, +respectively. [heading Examples] diff --git a/doc/find_not.qbk b/doc/find_not.qbk index a5a17cf..6df0482 100644 --- a/doc/find_not.qbk +++ b/doc/find_not.qbk @@ -23,9 +23,7 @@ the first occurrance of any number besides `1` in `vec`? We have to write an unfortunate amount of code: auto std::vector vec = { 1, 1, 2 }; - auto it = std::find_if( - vec.begin(), vec.end(), - [](int i) { return i != 1; }); + auto it = std::find_if(vec.begin(), vec.end(), [](int i) { return i != 1; }); With `find_not()` the code gets much more terse: @@ -35,18 +33,18 @@ With `find_not()` the code gets much more terse: The existing `find` variants are: `find()`, `find_if()`, and `find_if_not()`. It seems natural to also have `find_not()`, for the very reason that we have `find_if_not()` -- to avoid having to write a lambda to wrap the negation of -our find condition. +the find condition. [heading interface] template - InputIter find_not(InputIter first, Sentinel last, T const & x); + InputIter find_not(InputIter first, Sentinel last, const T & x); template - boost::range_iterator find_not(Range & r, T const & x); + boost::range_iterator find_not(Range & r, const T & x); -The function `find_not` returns the first value that is not equal to `x` in -the sequence `[first, last)` or `r`, respectively. +These overloads of `find_not` return the first value that is not equal to `x` +in the sequence `[first, last)` or `r`, respectively. [heading Examples] @@ -57,7 +55,7 @@ Given the container `c1` containing `{ 0, 1, 2 }`, then [heading Iterator Requirements] -`equal` works on all iterators except output iterators. +`find_not` works on all iterators except output iterators. The template parameter `Sentinel` is allowed to be different from `InputIter`, or they may be the same. For an `InputIter` `it` and a `Sentinel` `end`, `it