From 435cc61af82ee3abf581c75adf37ebaa2e62e54d Mon Sep 17 00:00:00 2001 From: Zach Laine Date: Tue, 2 Oct 2018 17:22:49 -0500 Subject: [PATCH 1/4] 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()`. From 01b0dd86483ce4c4975c0a1fe15ee1f8d5a22642 Mon Sep 17 00:00:00 2001 From: "James E. King III" Date: Sat, 27 Oct 2018 12:09:35 +0000 Subject: [PATCH 2/4] fix extraneous colon in test jamfile causing a build warning --- minmax/test/Jamfile.v2 | 2 +- test/Jamfile.v2 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/minmax/test/Jamfile.v2 b/minmax/test/Jamfile.v2 index fcfba8a..384b359 100644 --- a/minmax/test/Jamfile.v2 +++ b/minmax/test/Jamfile.v2 @@ -15,7 +15,7 @@ alias unit_test_framework ; { - test-suite algorithm/minmax: + test-suite algorithm/minmax : [ run minmax_element_test.cpp unit_test_framework : : : : minmax_element ] [ run minmax_test.cpp unit_test_framework diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 30cb786..e7091e0 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -16,7 +16,7 @@ alias unit_test_framework { - test-suite algorithm: + test-suite algorithm # Search tests : [ run empty_search_test.cpp unit_test_framework : : : : empty_search_test ] [ run search_test1.cpp unit_test_framework : : : : search_test1 ] From b6c04d6dc52ace864bb1f5cd26b65f9b639a39b9 Mon Sep 17 00:00:00 2001 From: Marshall Clow Date: Tue, 30 Oct 2018 15:23:29 -0700 Subject: [PATCH 3/4] Make apply_permutation work for C++03. Thanks to @jeking3 for the report. --- include/boost/algorithm/apply_permutation.hpp | 9 +++++---- test/apply_permutation_test.cpp | 1 - 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/boost/algorithm/apply_permutation.hpp b/include/boost/algorithm/apply_permutation.hpp index c844cfc..b9de0de 100644 --- a/include/boost/algorithm/apply_permutation.hpp +++ b/include/boost/algorithm/apply_permutation.hpp @@ -41,15 +41,16 @@ void apply_permutation(RandomAccessIterator1 item_begin, RandomAccessIterator1 item_end, RandomAccessIterator2 ind_begin, RandomAccessIterator2 ind_end) { - using Diff = typename std::iterator_traits::difference_type; + typedef typename std::iterator_traits::difference_type Diff; + typedef typename std::iterator_traits::difference_type Index; using std::swap; Diff size = std::distance(item_begin, item_end); for (Diff i = 0; i < size; i++) { - auto current = i; + Diff current = i; while (i != ind_begin[current]) { - auto next = ind_begin[current]; + Index next = ind_begin[current]; swap(item_begin[current], item_begin[next]); ind_begin[current] = current; current = next; @@ -75,7 +76,7 @@ apply_reverse_permutation( RandomAccessIterator2 ind_begin, RandomAccessIterator2 ind_end) { - using Diff = typename std::iterator_traits::difference_type; + typedef typename std::iterator_traits::difference_type Diff; using std::swap; Diff length = std::distance(item_begin, item_end); for (Diff i = 0; i < length; i++) diff --git a/test/apply_permutation_test.cpp b/test/apply_permutation_test.cpp index e9ab970..3dbb7e1 100644 --- a/test/apply_permutation_test.cpp +++ b/test/apply_permutation_test.cpp @@ -12,7 +12,6 @@ #include -#define BOOST_TEST_DYN_LINK #define BOOST_TEST_MAIN #include From 1cbe285841e073f4e7c685662c74bb6cf5be934b Mon Sep 17 00:00:00 2001 From: Marshall Clow Date: Thu, 1 Nov 2018 17:45:41 -0700 Subject: [PATCH 4/4] Fix bug in is_sorted docs; thanks to Tony E for the report: https://github.com/boostorg/algorithm/issues/54 --- doc/ordered-hpp.qbk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/ordered-hpp.qbk b/doc/ordered-hpp.qbk index 9e860d4..bc8c1a4 100644 --- a/doc/ordered-hpp.qbk +++ b/doc/ordered-hpp.qbk @@ -15,7 +15,7 @@ http://www.boost.org/LICENSE_1_0.txt) The header file `` contains functions for determining if a sequence is ordered. [heading is_sorted] -The function `is_sorted(sequence)` determines whether or not a sequence is completely sorted according so some criteria. If no comparison predicate is specified, then std::less_equal is used (i.e, the test is to see if the sequence is non-decreasing) +The function `is_sorted(sequence)` determines whether or not a sequence is completely sorted according so some criteria. If no comparison predicate is specified, then `std::less` is used (i.e, the test is to see if the sequence is non-decreasing) `` namespace boost { namespace algorithm {