From 435cc61af82ee3abf581c75adf37ebaa2e62e54d Mon Sep 17 00:00:00 2001 From: Zach Laine Date: Tue, 2 Oct 2018 17:22:49 -0500 Subject: [PATCH] Fix sloppy find_not() and find_*backward() code examples. --- doc/find_backward.qbk | 2 +- doc/find_not.qbk | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/find_backward.qbk b/doc/find_backward.qbk index 838dbc9..aa92de9 100644 --- a/doc/find_backward.qbk +++ b/doc/find_backward.qbk @@ -28,7 +28,7 @@ the use of `std::find()`: auto rfirst = std::make_reverse_iterator(last); auto rlast = std::make_reverse_iterator(first); - auto it = std::find(rfirst, rlast); + auto it = std::find(rfirst, rlast, x); // Use it here... That seems nicer in that there is no raw loop, but it has two major drawbacks. diff --git a/doc/find_not.qbk b/doc/find_not.qbk index 6df0482..be14979 100644 --- a/doc/find_not.qbk +++ b/doc/find_not.qbk @@ -15,19 +15,19 @@ equal to the given value. Consider this use of `find()`: - auto std::vector vec = { 1, 1, 2 }; + std::vector vec = { 1, 1, 2 }; auto it = std::find(vec.begin(), vec.end(), 1); This gives us the first occurance of `1` in `vec`. What if we want to find 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 }; + std::vector vec = { 1, 1, 2 }; auto it = std::find_if(vec.begin(), vec.end(), [](int i) { return i != 1; }); With `find_not()` the code gets much more terse: - auto std::vector vec = { 1, 1, 2 }; + std::vector vec = { 1, 1, 2 }; auto it = find_not(vec.begin(), vec.end(), 1); The existing `find` variants are: `find()`, `find_if()`, and `find_if_not()`.