From 8e0af8707a64d354500d13219d47e1cd4b0b6989 Mon Sep 17 00:00:00 2001 From: Jakub Mazurkiewicz Date: Mon, 19 Sep 2022 15:28:34 +0200 Subject: [PATCH 1/2] Fix bug --- stl/inc/algorithm | 4 ++-- .../tests/P0896R4_ranges_alg_is_permutation/test.cpp | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/stl/inc/algorithm b/stl/inc/algorithm index 7805a59839..9603d16134 100644 --- a/stl/inc/algorithm +++ b/stl/inc/algorithm @@ -957,7 +957,7 @@ namespace ranges { // We've trimmed matching prefixes and matching suffixes. // Now we need to compare each range's prefix to the other range's suffix. - const auto _ProjectedPred = [&](_Ty1&& _Left, _Ty2&& _Right) { + const auto _ProjectedPred = [&](_Ty1&& _Left, _Ty2&& _Right) -> bool { return _STD invoke(_Pred, _STD invoke(_Proj1, _STD forward<_Ty1>(_Left)), _STD invoke(_Proj2, _STD forward<_Ty2>(_Right))); }; @@ -1046,7 +1046,7 @@ namespace ranges { // We've trimmed matching prefixes and matching suffixes. // Now we need to compare each range's prefix to the other range's suffix. - const auto _ProjectedPred = [&](_Ty1&& _Left, _Ty2&& _Right) { + const auto _ProjectedPred = [&](_Ty1&& _Left, _Ty2&& _Right) -> bool { return _STD invoke(_Pred, _STD invoke(_Proj1, _STD forward<_Ty1>(_Left)), _STD invoke(_Proj2, _STD forward<_Ty2>(_Right))); }; diff --git a/tests/std/tests/P0896R4_ranges_alg_is_permutation/test.cpp b/tests/std/tests/P0896R4_ranges_alg_is_permutation/test.cpp index ea364cdcad..214ab04a16 100644 --- a/tests/std/tests/P0896R4_ranges_alg_is_permutation/test.cpp +++ b/tests/std/tests/P0896R4_ranges_alg_is_permutation/test.cpp @@ -134,6 +134,17 @@ struct instantiator { assert(ranges::is_permutation( r1, r2, {}, [](int n) { return n + 1; }, [](int n) { return n - 1; })); } + { // Test GH-2888: ``: `ranges::is_permutation`'s helper lambda does not specify return type + struct NonCopyableBool { + constexpr operator bool() { + return true; + }; + + NonCopyableBool() = default; + NonCopyableBool(const NonCopyableBool&) = delete; + } b; + assert(ranges::is_permutation(range2, range2, [&](auto, auto) -> NonCopyableBool& { return b; })); + } } }; From a4a4be4961a4c2731761634721a3eb95ed5ee9ff Mon Sep 17 00:00:00 2001 From: Casey Carter Date: Tue, 20 Sep 2022 08:09:13 -0700 Subject: [PATCH 2/2] remove extraneous semicolon --- tests/std/tests/P0896R4_ranges_alg_is_permutation/test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/std/tests/P0896R4_ranges_alg_is_permutation/test.cpp b/tests/std/tests/P0896R4_ranges_alg_is_permutation/test.cpp index 214ab04a16..e633850055 100644 --- a/tests/std/tests/P0896R4_ranges_alg_is_permutation/test.cpp +++ b/tests/std/tests/P0896R4_ranges_alg_is_permutation/test.cpp @@ -138,7 +138,7 @@ struct instantiator { struct NonCopyableBool { constexpr operator bool() { return true; - }; + } NonCopyableBool() = default; NonCopyableBool(const NonCopyableBool&) = delete;