Skip to content

Commit 6b22464

Browse files
committed
find_{not,*backward} docs copy editing.
1 parent c5c5d24 commit 6b22464

File tree

2 files changed

+27
-28
lines changed

2 files changed

+27
-28
lines changed

doc/find_backward.qbk

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Distributed under the Boost Software License, Version 1.0.
1111

1212
The header file 'find_backward.hpp' contains variants of the stl algorithm
1313
`find`. These variants are like `find`, except that the evaluate the elements
14-
of the given sequence if reverse order.
14+
of the given sequence in reverse order.
1515

1616
Consider how finding the last element that is equal to `x` in a range is
1717
typically done:
@@ -23,57 +23,58 @@ typically done:
2323
}
2424
}
2525

26-
Raw loops are icky though. PErhaps we should do a bit of extra work to allow
26+
Raw loops are icky though. Perhaps we should do a bit of extra work to allow
2727
the use of `std::find()`:
2828

2929
auto rfirst = std::make_reverse_iterator(last);
3030
auto rlast = std::make_reverse_iterator(first);
3131
auto it = std::find(rfirst, rlast);
3232
// Use it here...
3333

34-
That seems nicer, but it has two major drawbacks. First, it requires an
35-
unpleasant amount of typing. Second, it is considerably less efficient than
36-
forward-iterator `find` , since `std::reverse_iterator` calls its
37-
base-iterator's `operator--()` in most of its members before doing the work
38-
that the member requires.
34+
That seems nicer in that there is no raw loop, but it has two major drawbacks.
35+
First, it requires an unpleasant amount of typing. Second, it is less
36+
efficient than forward-iterator `find` , since `std::reverse_iterator` calls
37+
its base-iterator's `operator--()` in most of its member functions before
38+
doing the work that the member function requires.
3939

4040
[heading interface]
4141

4242
template<typename BidiIter, typename T>
43-
BidiIter find_backward(BidiIter first, BidiIter last, T const & x);
43+
BidiIter find_backward(BidiIter first, BidiIter last, const T & x);
4444

4545
template<typename Range, typename T>
46-
boost::range_iterator<Range> find_backward(Range & range, T const & x);
46+
boost::range_iterator<Range> find_backward(Range & range, const T & x);
4747

48-
The function `find_backward` returns an iterator to the last element that is
49-
equal to `x` in `[first, last)` or `r`, respectively.
48+
These overloads of `find_backward` return an iterator to the last element that
49+
is equal to `x` in `[first, last)` or `r`, respectively.
5050

5151
template<typename BidiIter, typename T>
52-
BidiIter find_not_backward(BidiIter first, BidiIter last, T const & x);
52+
BidiIter find_not_backward(BidiIter first, BidiIter last, const T & x);
5353

5454
template<typename Range, typename T>
55-
boost::range_iterator<Range> find_not_backward(Range & range, T const & x);
55+
boost::range_iterator<Range> find_not_backward(Range & range, const T & x);
5656

57-
The function `find_not_backward` returns an iterator to the last element that
58-
is not equal to `x` in `[first, last)` or `r`, respectively.
57+
These overloads of `find_not_backward` return an iterator to the last element
58+
that is not equal to `x` in `[first, last)` or `r`, respectively.
5959

6060
template<typename BidiIter, typename Pred>
6161
BidiIter find_if_backward(BidiIter first, BidiIter last, Pred p);
6262

6363
template<typename Range, typename Pred>
6464
boost::range_iterator<Range> find_if_backward(Range & range, Pred p);
6565

66-
The function `find_if_backward` returns an iterator to the last element for
67-
which `pred` returns `true` in `[first, last)` or `r`, respectively.
66+
These overloads of `find_if_backward` return an iterator to the last element
67+
for which `pred` returns `true` in `[first, last)` or `r`, respectively.
6868

6969
template<typename BidiIter, typename Pred>
7070
BidiIter find_if_not_backward(BidiIter first, BidiIter last, Pred p);
7171

7272
template<typename Range, typename Pred>
7373
boost::range_iterator<Range> find_if_not_backward(Range & range, Pred p);
7474

75-
The function `find_if_not_backward` returns an iterator to the last element
76-
for which `pred` returns `false` in `[first, last)` or `r`, respectively.
75+
These overloads of `find_if_not_backward` return an iterator to the last
76+
element for which `pred` returns `false` in `[first, last)` or `r`,
77+
respectively.
7778

7879
[heading Examples]
7980

doc/find_not.qbk

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ the first occurrance of any number besides `1` in `vec`? We have to write an
2323
unfortunate amount of code:
2424

2525
auto std::vector<int> vec = { 1, 1, 2 };
26-
auto it = std::find_if(
27-
vec.begin(), vec.end(),
28-
[](int i) { return i != 1; });
26+
auto it = std::find_if(vec.begin(), vec.end(), [](int i) { return i != 1; });
2927

3028
With `find_not()` the code gets much more terse:
3129

@@ -35,18 +33,18 @@ With `find_not()` the code gets much more terse:
3533
The existing `find` variants are: `find()`, `find_if()`, and `find_if_not()`.
3634
It seems natural to also have `find_not()`, for the very reason that we have
3735
`find_if_not()` -- to avoid having to write a lambda to wrap the negation of
38-
our find condition.
36+
the find condition.
3937

4038
[heading interface]
4139

4240
template<typename InputIter, typename Sentinel, typename T>
43-
InputIter find_not(InputIter first, Sentinel last, T const & x);
41+
InputIter find_not(InputIter first, Sentinel last, const T & x);
4442

4543
template<typename Range, typename T>
46-
boost::range_iterator<Range> find_not(Range & r, T const & x);
44+
boost::range_iterator<Range> find_not(Range & r, const T & x);
4745

48-
The function `find_not` returns the first value that is not equal to `x` in
49-
the sequence `[first, last)` or `r`, respectively.
46+
These overloads of `find_not` return the first value that is not equal to `x`
47+
in the sequence `[first, last)` or `r`, respectively.
5048

5149
[heading Examples]
5250

@@ -57,7 +55,7 @@ Given the container `c1` containing `{ 0, 1, 2 }`, then
5755

5856
[heading Iterator Requirements]
5957

60-
`equal` works on all iterators except output iterators.
58+
`find_not` works on all iterators except output iterators.
6159

6260
The template parameter `Sentinel` is allowed to be different from `InputIter`,
6361
or they may be the same. For an `InputIter` `it` and a `Sentinel` `end`, `it

0 commit comments

Comments
 (0)