From 19c2a1583e722ba048bea6639f4486daedb43bdb Mon Sep 17 00:00:00 2001 From: Ahana Mukhopadhyay Date: Mon, 8 Jun 2020 15:15:12 -0400 Subject: [PATCH 01/22] added the move algorithm on line 1265 of algorithm and created a new folder with test --- stl/inc/algorithm | 39 +++++++++++++ tests/std/test.lst | 1 + .../std/tests/P0896R4_ranges_alg_move/env.lst | 4 ++ .../tests/P0896R4_ranges_alg_move/test.cpp | 55 +++++++++++++++++++ 4 files changed, 99 insertions(+) create mode 100644 tests/std/tests/P0896R4_ranges_alg_move/env.lst create mode 100644 tests/std/tests/P0896R4_ranges_alg_move/test.cpp diff --git a/stl/inc/algorithm b/stl/inc/algorithm index b6a009c14d..9ce194acd0 100644 --- a/stl/inc/algorithm +++ b/stl/inc/algorithm @@ -1263,6 +1263,43 @@ namespace ranges { } // namespace ranges #endif // __cpp_lib_concepts +#ifdef __cpp_lib_concepts + +namespace ranges { + // ALIAS TEMPLATE copy_result + template + using move_result = in_out_result<_In, _Out>; + + class _Move_fn : private _Not_quite_object { + public: + using _Not_quite_object::_Not_quite_object; + + template _Se, weakly_incrementable _Out> + requires indirectly_movable<_It, _Out> constexpr move_result<_It, _Out> operator()( + _It _First, _Se _Last, _Out _Result) const { + _Adl_verify_range(_First, _Last); + auto _UFirst = _Get_unwrapped(_STD move(_First)); + const auto _ULast = _Get_unwrapped(_STD move(_Last)); + for (; _UFirst != _ULast; ++_UFirst, (void) ++_Result) { + *_Result = _RANGES iter_move(_UFirst); + } + + _Seek_wrapped(_First, _STD move(_UFirst)); + return {_STD move(_UFirst), _STD move(_Result)}; + } + + template + requires indirectly_movable, _Out> constexpr move_result, _Out> + operator()(_Rng&& _Range, _Out _Result) const { + return (*this)(_RANGES begin(_Range), _RANGES end(_Range), _STD move(_Result)); + } + }; + + inline constexpr _Move_fn move{_Not_quite_object::_Construct_tag{}}; +} // namespace ranges +#endif // __cpp_lib_concepts + + // FUNCTION TEMPLATE partition_copy template _CONSTEXPR20 pair<_OutIt1, _OutIt2> partition_copy( @@ -5173,6 +5210,8 @@ _NODISCARD constexpr const _Ty& clamp(const _Ty& _Val, const _Ty& _Min_val, cons } #endif // _HAS_CXX17 + + _STD_END #pragma pop_macro("new") _STL_RESTORE_CLANG_WARNINGS diff --git a/tests/std/test.lst b/tests/std/test.lst index 08cc1aec9f..1ac2abf208 100644 --- a/tests/std/test.lst +++ b/tests/std/test.lst @@ -249,6 +249,7 @@ tests\P0896R4_ranges_alg_find_if_not tests\P0896R4_ranges_alg_for_each tests\P0896R4_ranges_alg_for_each_n tests\P0896R4_ranges_alg_mismatch +tests\P0896R4_ranges_alg_move tests\P0896R4_ranges_alg_none_of tests\P0896R4_ranges_iterator_machinery tests\P0896R4_ranges_range_machinery diff --git a/tests/std/tests/P0896R4_ranges_alg_move/env.lst b/tests/std/tests/P0896R4_ranges_alg_move/env.lst new file mode 100644 index 0000000000..f3ccc8613c --- /dev/null +++ b/tests/std/tests/P0896R4_ranges_alg_move/env.lst @@ -0,0 +1,4 @@ +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +RUNALL_INCLUDE ..\concepts_matrix.lst diff --git a/tests/std/tests/P0896R4_ranges_alg_move/test.cpp b/tests/std/tests/P0896R4_ranges_alg_move/test.cpp new file mode 100644 index 0000000000..d32f8f8e2e --- /dev/null +++ b/tests/std/tests/P0896R4_ranges_alg_move/test.cpp @@ -0,0 +1,55 @@ +#include +#include +#include +#include +#include +#include +#include + +void smoke_test() { + using ranges::move, ranges::move_result, ranges::iterator_t; + using std::same_as; + + // Validate that copy_result aliases in_out_result + STATIC_ASSERT(same_as, ranges::in_out_result>); + + // Validate dangling story + STATIC_ASSERT(same_as{}, static_cast(nullptr))), move_result>); + STATIC_ASSERT(same_as{}, static_cast(nullptr))), move_result>); + + int const input[] = {13, 53, 12435}; + { + int output[] = {-1, -1, -1}; + auto result = move(move_only_range{input}, move_only_range{output}.begin()); + STATIC_ASSERT(same_as>, iterator_t>>>); + std::cout << std::to_address(result.in.base()) << ' ' << std::to_address(move_only_range{input}.end().base()) << std::endl; + assert(result.in == move_only_range{input}.end()); + assert(result.out == move_only_range{output}.end()); + assert(ranges::equal(output, input)); + } + { + int output[] = {-1, -1, -1}; + move_only_range wrapped_input{input}; + auto result = move(wrapped_input.begin(), wrapped_input.end(), move_only_range{output}.begin()); + STATIC_ASSERT(same_as>, iterator_t>>>); + assert(result.in == wrapped_input.end()); + assert(result.out == move_only_range{output}.end()); + assert(ranges::equal(output, input)); + } +} + +int main() { + // STATIC_ASSERT((smoke_test(), true)); + smoke_test(); +} + +struct instantiator { + template + static void call(In&& in = {}, Out out = {}) { + (void) ranges::move(in, std::move(out)); + (void) ranges::move(ranges::begin(in), ranges::end(in), std::move(out)); // what is this + } +}; + +template void test_in_out(); \ No newline at end of file From 354e48bb550827785c20126223fa7907d1a82909 Mon Sep 17 00:00:00 2001 From: Ahana Mukhopadhyay Date: Mon, 8 Jun 2020 15:16:37 -0400 Subject: [PATCH 02/22] added cmake file --- cmake | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 cmake diff --git a/cmake b/cmake new file mode 100644 index 0000000000..e69de29bb2 From 09f6c9febfdd68905208dc60f07129141e8e91ed Mon Sep 17 00:00:00 2001 From: Ahana Mukhopadhyay Date: Mon, 8 Jun 2020 15:44:29 -0400 Subject: [PATCH 03/22] passing all tests for ranges move algorithm --- stl/inc/algorithm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stl/inc/algorithm b/stl/inc/algorithm index 9ce194acd0..3ebd1b3b2d 100644 --- a/stl/inc/algorithm +++ b/stl/inc/algorithm @@ -1285,7 +1285,7 @@ namespace ranges { } _Seek_wrapped(_First, _STD move(_UFirst)); - return {_STD move(_UFirst), _STD move(_Result)}; + return {_STD move(_First), _STD move(_Result)}; } template From 61375a9f778b037ea0f15f1b744db3aa1c6ddf8b Mon Sep 17 00:00:00 2001 From: Ahana Mukhopadhyay Date: Tue, 9 Jun 2020 14:34:09 -0400 Subject: [PATCH 04/22] updated move algo tests to check that we actually move elems, not just copy --- .../tests/P0896R4_ranges_alg_move/test.cpp | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/tests/std/tests/P0896R4_ranges_alg_move/test.cpp b/tests/std/tests/P0896R4_ranges_alg_move/test.cpp index d32f8f8e2e..51b7078666 100644 --- a/tests/std/tests/P0896R4_ranges_alg_move/test.cpp +++ b/tests/std/tests/P0896R4_ranges_alg_move/test.cpp @@ -6,6 +6,17 @@ #include #include +struct int_wrapper { + int val = 10; + int_wrapper() = default; + int_wrapper(int x) : val{x} {} + int_wrapper(int_wrapper&& that) : val{std::exchange(that.val, -1)} {} + int_wrapper& operator=(int_wrapper&& that) { + val = std::exchange(that.val, -1); + return *this; + } +}; + void smoke_test() { using ranges::move, ranges::move_result, ranges::iterator_t; using std::same_as; @@ -37,6 +48,29 @@ void smoke_test() { assert(result.out == move_only_range{output}.end()); assert(ranges::equal(output, input)); } + { + int_wrapper input1[3]; + input1[0] = int_wrapper(13); + input1[1] = int_wrapper(55); + input1[2] = int_wrapper(1234); + int_wrapper expected_output[3]; + expected_output[0] = int_wrapper(13); + expected_output[1] = int_wrapper(55); + expected_output[2] = int_wrapper(1234); + int_wrapper actual_output[3]; + for (int i = 0; i < 3; i++) { + actual_output[i] = int_wrapper(-1); + } + move_only_range wrapped_input{input1}; + auto result = move(wrapped_input.begin(), wrapped_input.end(), move_only_range{actual_output}.begin()); + assert(result.in == wrapped_input.end()); + assert(result.out == move_only_range{actual_output}.end()); + for (int i = 0; i < 3; i++) { + assert(input1[i].val == -1); + assert(actual_output[i].val == expected_output[i].val); + } + } + } int main() { From 68640ed60549c88e2336b38eb94f7921386b213d Mon Sep 17 00:00:00 2001 From: Ahana Mukhopadhyay Date: Tue, 9 Jun 2020 15:02:28 -0400 Subject: [PATCH 05/22] enabled constexpr, cleaned up move algo test --- .../tests/P0896R4_ranges_alg_move/test.cpp | 32 +++++++------------ 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/tests/std/tests/P0896R4_ranges_alg_move/test.cpp b/tests/std/tests/P0896R4_ranges_alg_move/test.cpp index 51b7078666..a7641cc22b 100644 --- a/tests/std/tests/P0896R4_ranges_alg_move/test.cpp +++ b/tests/std/tests/P0896R4_ranges_alg_move/test.cpp @@ -8,20 +8,20 @@ struct int_wrapper { int val = 10; - int_wrapper() = default; - int_wrapper(int x) : val{x} {} - int_wrapper(int_wrapper&& that) : val{std::exchange(that.val, -1)} {} - int_wrapper& operator=(int_wrapper&& that) { + constexpr int_wrapper() = default; + constexpr int_wrapper(int x) : val{x} {} + constexpr int_wrapper(int_wrapper&& that) : val{std::exchange(that.val, -1)} {} + constexpr int_wrapper& operator=(int_wrapper&& that) { val = std::exchange(that.val, -1); return *this; } }; -void smoke_test() { +constexpr void smoke_test() { using ranges::move, ranges::move_result, ranges::iterator_t; using std::same_as; - // Validate that copy_result aliases in_out_result + // Validate that move_result aliases in_out_result STATIC_ASSERT(same_as, ranges::in_out_result>); // Validate dangling story @@ -34,7 +34,6 @@ void smoke_test() { auto result = move(move_only_range{input}, move_only_range{output}.begin()); STATIC_ASSERT(same_as>, iterator_t>>>); - std::cout << std::to_address(result.in.base()) << ' ' << std::to_address(move_only_range{input}.end().base()) << std::endl; assert(result.in == move_only_range{input}.end()); assert(result.out == move_only_range{output}.end()); assert(ranges::equal(output, input)); @@ -49,32 +48,23 @@ void smoke_test() { assert(ranges::equal(output, input)); } { - int_wrapper input1[3]; - input1[0] = int_wrapper(13); - input1[1] = int_wrapper(55); - input1[2] = int_wrapper(1234); - int_wrapper expected_output[3]; - expected_output[0] = int_wrapper(13); - expected_output[1] = int_wrapper(55); - expected_output[2] = int_wrapper(1234); - int_wrapper actual_output[3]; - for (int i = 0; i < 3; i++) { - actual_output[i] = int_wrapper(-1); - } + int_wrapper input1[3] = {13, 55, 1234}; + int expected_output[3] = {13, 55, 1234}; + int_wrapper actual_output[3] = {-1, -1, -1}; move_only_range wrapped_input{input1}; auto result = move(wrapped_input.begin(), wrapped_input.end(), move_only_range{actual_output}.begin()); assert(result.in == wrapped_input.end()); assert(result.out == move_only_range{actual_output}.end()); for (int i = 0; i < 3; i++) { assert(input1[i].val == -1); - assert(actual_output[i].val == expected_output[i].val); + assert(actual_output[i].val == expected_output[i]); } } } int main() { - // STATIC_ASSERT((smoke_test(), true)); + STATIC_ASSERT((smoke_test(), true)); smoke_test(); } From 52775525c8164b970827640dcd3b41b72e80df57 Mon Sep 17 00:00:00 2001 From: Ahana Mukhopadhyay Date: Tue, 9 Jun 2020 15:08:34 -0400 Subject: [PATCH 06/22] removed iostream unused header --- tests/std/tests/P0896R4_ranges_alg_move/test.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/std/tests/P0896R4_ranges_alg_move/test.cpp b/tests/std/tests/P0896R4_ranges_alg_move/test.cpp index a7641cc22b..74bcac8cb5 100644 --- a/tests/std/tests/P0896R4_ranges_alg_move/test.cpp +++ b/tests/std/tests/P0896R4_ranges_alg_move/test.cpp @@ -2,7 +2,6 @@ #include #include #include -#include #include #include From 45fb14d92285012b6fb4d69101c6d6ef0fed09fa Mon Sep 17 00:00:00 2001 From: Ahana Mukhopadhyay Date: Wed, 10 Jun 2020 11:28:01 -0400 Subject: [PATCH 07/22] mainly updated formatting/comments based on feedback --- stl/inc/algorithm | 15 ++++++++------- tests/std/tests/P0896R4_ranges_alg_move/test.cpp | 9 ++++++--- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/stl/inc/algorithm b/stl/inc/algorithm index 3ebd1b3b2d..55a9f1e847 100644 --- a/stl/inc/algorithm +++ b/stl/inc/algorithm @@ -1264,18 +1264,20 @@ namespace ranges { #endif // __cpp_lib_concepts #ifdef __cpp_lib_concepts - namespace ranges { - // ALIAS TEMPLATE copy_result + // ALIAS TEMPLATE move_result template using move_result = in_out_result<_In, _Out>; + // VARIABLE ranges::move class _Move_fn : private _Not_quite_object { public: using _Not_quite_object::_Not_quite_object; + // clang-format off template _Se, weakly_incrementable _Out> - requires indirectly_movable<_It, _Out> constexpr move_result<_It, _Out> operator()( + requires indirectly_movable<_It, _Out> + constexpr move_result<_It, _Out> operator()( _It _First, _Se _Last, _Out _Result) const { _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_STD move(_First)); @@ -1289,17 +1291,18 @@ namespace ranges { } template - requires indirectly_movable, _Out> constexpr move_result, _Out> + requires indirectly_movable, _Out> + constexpr move_result, _Out> operator()(_Rng&& _Range, _Out _Result) const { return (*this)(_RANGES begin(_Range), _RANGES end(_Range), _STD move(_Result)); } + // clang-format on }; inline constexpr _Move_fn move{_Not_quite_object::_Construct_tag{}}; } // namespace ranges #endif // __cpp_lib_concepts - // FUNCTION TEMPLATE partition_copy template _CONSTEXPR20 pair<_OutIt1, _OutIt2> partition_copy( @@ -5210,8 +5213,6 @@ _NODISCARD constexpr const _Ty& clamp(const _Ty& _Val, const _Ty& _Min_val, cons } #endif // _HAS_CXX17 - - _STD_END #pragma pop_macro("new") _STL_RESTORE_CLANG_WARNINGS diff --git a/tests/std/tests/P0896R4_ranges_alg_move/test.cpp b/tests/std/tests/P0896R4_ranges_alg_move/test.cpp index 74bcac8cb5..c5f7e4c841 100644 --- a/tests/std/tests/P0896R4_ranges_alg_move/test.cpp +++ b/tests/std/tests/P0896R4_ranges_alg_move/test.cpp @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + #include #include #include @@ -54,7 +57,7 @@ constexpr void smoke_test() { auto result = move(wrapped_input.begin(), wrapped_input.end(), move_only_range{actual_output}.begin()); assert(result.in == wrapped_input.end()); assert(result.out == move_only_range{actual_output}.end()); - for (int i = 0; i < 3; i++) { + for (int i = 0; i < 3; ++i) { assert(input1[i].val == -1); assert(actual_output[i].val == expected_output[i]); } @@ -71,8 +74,8 @@ struct instantiator { template static void call(In&& in = {}, Out out = {}) { (void) ranges::move(in, std::move(out)); - (void) ranges::move(ranges::begin(in), ranges::end(in), std::move(out)); // what is this + (void) ranges::move(ranges::begin(in), ranges::end(in), std::move(out)); } }; -template void test_in_out(); \ No newline at end of file +template void test_in_out(); From 80e349e50db39a1d47bc6774eeb4b4d560985b22 Mon Sep 17 00:00:00 2001 From: ahanamuk Date: Wed, 10 Jun 2020 11:33:47 -0400 Subject: [PATCH 08/22] Delete cmake --- cmake | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 cmake diff --git a/cmake b/cmake deleted file mode 100644 index e69de29bb2..0000000000 From d4f91b0c81c0512e66fb9a5c0438f14e080e703a Mon Sep 17 00:00:00 2001 From: Ahana Mukhopadhyay Date: Thu, 11 Jun 2020 13:20:56 -0400 Subject: [PATCH 09/22] modified a test --- tests/std/tests/P0896R4_ranges_alg_move/test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/std/tests/P0896R4_ranges_alg_move/test.cpp b/tests/std/tests/P0896R4_ranges_alg_move/test.cpp index c5f7e4c841..c2f8925470 100644 --- a/tests/std/tests/P0896R4_ranges_alg_move/test.cpp +++ b/tests/std/tests/P0896R4_ranges_alg_move/test.cpp @@ -52,7 +52,7 @@ constexpr void smoke_test() { { int_wrapper input1[3] = {13, 55, 1234}; int expected_output[3] = {13, 55, 1234}; - int_wrapper actual_output[3] = {-1, -1, -1}; + int_wrapper actual_output[3] = {-2, -2, -2}; move_only_range wrapped_input{input1}; auto result = move(wrapped_input.begin(), wrapped_input.end(), move_only_range{actual_output}.begin()); assert(result.in == wrapped_input.end()); From c9f134f7b8bbc4bde4d4d87a42a6f493552b5968 Mon Sep 17 00:00:00 2001 From: Ahana Mukhopadhyay Date: Thu, 11 Jun 2020 13:35:17 -0400 Subject: [PATCH 10/22] initial fill algo --- stl/inc/algorithm | 35 +++++++++++++++++ tests/std/test.lst | 1 + .../std/tests/P0896R4_ranges_alg_fill/env.lst | 4 ++ .../tests/P0896R4_ranges_alg_fill/test.cpp | 39 +++++++++++++++++++ 4 files changed, 79 insertions(+) create mode 100644 tests/std/tests/P0896R4_ranges_alg_fill/env.lst create mode 100644 tests/std/tests/P0896R4_ranges_alg_fill/test.cpp diff --git a/stl/inc/algorithm b/stl/inc/algorithm index 55a9f1e847..943226e6ac 100644 --- a/stl/inc/algorithm +++ b/stl/inc/algorithm @@ -2388,6 +2388,41 @@ _FwdIt2 replace_copy_if(_ExPo&&, _FwdIt1 _First, _FwdIt1 _Last, _FwdIt2 _Dest, _ } #endif // _HAS_CXX17 +#ifdef __cpp_lib_concepts +namespace ranges { + template + + // VARIABLE ranges::fill + class _Fill_fn : private _Not_quite_object { + public: + using _Not_quite_object::_Not_quite_object; + + // clang-format off + template _O, sentinel_for<_O> _S> + constexpr _O operator()(_O _First, _S _Last, const _T& _Value) const { + _Adl_verify_range(_First, _Last); + auto _UFirst = _Get_unwrapped(_STD move(_First)); + auto _ULast = _Get_unwrapped(_STD move(_Last)); + while (_UFirst != _ULast) { + *_UFirst = _Value; + ++_UFirst; + } + + _Seek_wrapped(_First, _STD move(_UFirst)); + return _First; + } + + template _Rng> + constexpr borrowed_iterator_t<_Rng> operator()(_Rng&& _Range, const _T& _Value) const { + return (*this)(_RANGES begin(_Range), _RANGES end(_Range), _Value) + } + // clang-format on + }; + + inline constexpr _Fill_fn fill{_Not_quite_object::_Construct_tag{}}; +} // namespace ranges +#endif // __cpp_lib_concepts + // FUNCTION TEMPLATE generate template _CONSTEXPR20 void generate(_FwdIt _First, _FwdIt _Last, _Fn _Func) { // replace [_First, _Last) with _Func() diff --git a/tests/std/test.lst b/tests/std/test.lst index 1ac2abf208..d9ab9d6ee7 100644 --- a/tests/std/test.lst +++ b/tests/std/test.lst @@ -241,6 +241,7 @@ tests\P0896R4_ranges_alg_copy_n tests\P0896R4_ranges_alg_count tests\P0896R4_ranges_alg_count_if tests\P0896R4_ranges_alg_equal +tests\P0896R4_ranges_alg_fill tests\P0896R4_ranges_alg_find tests\P0896R4_ranges_alg_find_end tests\P0896R4_ranges_alg_find_first_of diff --git a/tests/std/tests/P0896R4_ranges_alg_fill/env.lst b/tests/std/tests/P0896R4_ranges_alg_fill/env.lst new file mode 100644 index 0000000000..f3ccc8613c --- /dev/null +++ b/tests/std/tests/P0896R4_ranges_alg_fill/env.lst @@ -0,0 +1,4 @@ +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +RUNALL_INCLUDE ..\concepts_matrix.lst diff --git a/tests/std/tests/P0896R4_ranges_alg_fill/test.cpp b/tests/std/tests/P0896R4_ranges_alg_fill/test.cpp new file mode 100644 index 0000000000..e65197dd78 --- /dev/null +++ b/tests/std/tests/P0896R4_ranges_alg_fill/test.cpp @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include +#include +#include +#include +#include +#include + +constexpr void smoke_test() { + using ranges::fill, ranges::iterator_t; + using std::same_as; + + int output[] = {13, 42, 1367}; + { + const int value = 7; + auto result = fill(output.begin(), output.end(), value); + for (int i = 0; i < 3; ++i) { + assert(output[i] == 7); + } + assert(result == output.end()); + } +} + +int main() { + // STATIC_ASSERT((smoke_test(), true)); + smoke_test(); +} + +struct instantiator { + template + static void call(In&& in = {}) { + (void) ranges::fill(in, SOMETHING); + (void) ranges::fill(ranges::begin(in), ranges::end(in), SOMETHING); + } +}; + +template void test_in_out(); From 93ff9476be4433c53955dacfe5585ea25d1e13f2 Mon Sep 17 00:00:00 2001 From: Ahana Mukhopadhyay Date: Thu, 11 Jun 2020 14:52:24 -0400 Subject: [PATCH 11/22] Passing all fill tests --- stl/inc/algorithm | 4 +-- tests/std/include/range_algorithm_support.hpp | 27 ++++++++++++++++++- .../tests/P0896R4_ranges_alg_fill/test.cpp | 16 +++++------ 3 files changed, 36 insertions(+), 11 deletions(-) diff --git a/stl/inc/algorithm b/stl/inc/algorithm index 943226e6ac..7d97d806ff 100644 --- a/stl/inc/algorithm +++ b/stl/inc/algorithm @@ -2390,7 +2390,7 @@ _FwdIt2 replace_copy_if(_ExPo&&, _FwdIt1 _First, _FwdIt1 _Last, _FwdIt2 _Dest, _ #ifdef __cpp_lib_concepts namespace ranges { - template + // template // VARIABLE ranges::fill class _Fill_fn : private _Not_quite_object { @@ -2414,7 +2414,7 @@ namespace ranges { template _Rng> constexpr borrowed_iterator_t<_Rng> operator()(_Rng&& _Range, const _T& _Value) const { - return (*this)(_RANGES begin(_Range), _RANGES end(_Range), _Value) + return (*this)(_RANGES begin(_Range), _RANGES end(_Range), _Value); } // clang-format on }; diff --git a/tests/std/include/range_algorithm_support.hpp b/tests/std/include/range_algorithm_support.hpp index cc0d77625a..27a852a3ff 100644 --- a/tests/std/include/range_algorithm_support.hpp +++ b/tests/std/include/range_algorithm_support.hpp @@ -488,6 +488,31 @@ struct with_input_ranges { } }; +template +struct with_output_ranges { + template + static void call() { + Continuation::template call>(); + Continuation::template call>(); + + Continuation::template call>(); + Continuation::template call>(); + Continuation::template call>(); + Continuation::template call>(); + + Continuation::template call>(); + Continuation::template call>(); + Continuation::template call>(); + Continuation::template call>(); + + Continuation::template call>(); + Continuation::template call>(); + + Continuation::template call>(); + Continuation::template call>(); + } +}; + template struct with_forward_ranges { template @@ -534,7 +559,7 @@ struct with_difference { template void test_out() { - with_output_iterators::call(); + with_output_ranges::call(); } template diff --git a/tests/std/tests/P0896R4_ranges_alg_fill/test.cpp b/tests/std/tests/P0896R4_ranges_alg_fill/test.cpp index e65197dd78..009b600bc8 100644 --- a/tests/std/tests/P0896R4_ranges_alg_fill/test.cpp +++ b/tests/std/tests/P0896R4_ranges_alg_fill/test.cpp @@ -15,25 +15,25 @@ constexpr void smoke_test() { int output[] = {13, 42, 1367}; { const int value = 7; - auto result = fill(output.begin(), output.end(), value); + auto result = fill(std::begin(output), std::end(output), value); for (int i = 0; i < 3; ++i) { assert(output[i] == 7); } - assert(result == output.end()); + assert(result == std::end(output)); } } int main() { - // STATIC_ASSERT((smoke_test(), true)); + STATIC_ASSERT((smoke_test(), true)); smoke_test(); } struct instantiator { - template - static void call(In&& in = {}) { - (void) ranges::fill(in, SOMETHING); - (void) ranges::fill(ranges::begin(in), ranges::end(in), SOMETHING); + template + static void call(Out&& out = {}) { + (void) ranges::fill(out, 42); + (void) ranges::fill(ranges::begin(out), ranges::end(out), 42); } }; -template void test_in_out(); +template void test_out(); From be947f1103785549012bb328b2d06cbd1d0e038a Mon Sep 17 00:00:00 2001 From: Ahana Mukhopadhyay Date: Thu, 11 Jun 2020 14:59:07 -0400 Subject: [PATCH 12/22] added a test case --- .../std/tests/P0896R4_ranges_alg_fill/test.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/tests/std/tests/P0896R4_ranges_alg_fill/test.cpp b/tests/std/tests/P0896R4_ranges_alg_fill/test.cpp index 009b600bc8..a9021bcb1f 100644 --- a/tests/std/tests/P0896R4_ranges_alg_fill/test.cpp +++ b/tests/std/tests/P0896R4_ranges_alg_fill/test.cpp @@ -12,15 +12,25 @@ constexpr void smoke_test() { using ranges::fill, ranges::iterator_t; using std::same_as; - int output[] = {13, 42, 1367}; + int output1[] = {13, 42, 1367}; + int output2[] = {13, 42, 1367}; { const int value = 7; - auto result = fill(std::begin(output), std::end(output), value); + auto result = fill(std::begin(output1), std::end(output1), value); for (int i = 0; i < 3; ++i) { - assert(output[i] == 7); + assert(output1[i] == 7); } - assert(result == std::end(output)); + assert(result == std::end(output1)); } + { + const int value = 13; + auto result = fill(output2, value); + for (int i = 0; i < 3; ++i) { + assert(output2[i] == 13); + } + assert(result == std::end(output2)); + } + } int main() { From 5cb7bfcf72a72149a916d18a3078ea78a99360c8 Mon Sep 17 00:00:00 2001 From: Ahana Mukhopadhyay Date: Fri, 12 Jun 2020 11:27:00 -0400 Subject: [PATCH 13/22] minor changes/formatting updates to move --- stl/inc/algorithm | 5 +---- tests/std/tests/P0896R4_ranges_alg_move/test.cpp | 8 +++++--- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/stl/inc/algorithm b/stl/inc/algorithm index 7d97d806ff..d9815fc2dc 100644 --- a/stl/inc/algorithm +++ b/stl/inc/algorithm @@ -1261,9 +1261,7 @@ namespace ranges { inline constexpr _Copy_if_fn copy_if{_Not_quite_object::_Construct_tag{}}; } // namespace ranges -#endif // __cpp_lib_concepts -#ifdef __cpp_lib_concepts namespace ranges { // ALIAS TEMPLATE move_result template @@ -1277,8 +1275,7 @@ namespace ranges { // clang-format off template _Se, weakly_incrementable _Out> requires indirectly_movable<_It, _Out> - constexpr move_result<_It, _Out> operator()( - _It _First, _Se _Last, _Out _Result) const { + constexpr move_result<_It, _Out> operator()(_It _First, _Se _Last, _Out _Result) const { _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_STD move(_First)); const auto _ULast = _Get_unwrapped(_STD move(_Last)); diff --git a/tests/std/tests/P0896R4_ranges_alg_move/test.cpp b/tests/std/tests/P0896R4_ranges_alg_move/test.cpp index c2f8925470..0e80d08c8d 100644 --- a/tests/std/tests/P0896R4_ranges_alg_move/test.cpp +++ b/tests/std/tests/P0896R4_ranges_alg_move/test.cpp @@ -27,8 +27,10 @@ constexpr void smoke_test() { STATIC_ASSERT(same_as, ranges::in_out_result>); // Validate dangling story - STATIC_ASSERT(same_as{}, static_cast(nullptr))), move_result>); - STATIC_ASSERT(same_as{}, static_cast(nullptr))), move_result>); + STATIC_ASSERT(same_as{}, static_cast(nullptr))), + move_result>); + STATIC_ASSERT(same_as{}, static_cast(nullptr))), + move_result>); int const input[] = {13, 53, 12435}; { @@ -51,7 +53,7 @@ constexpr void smoke_test() { } { int_wrapper input1[3] = {13, 55, 1234}; - int expected_output[3] = {13, 55, 1234}; + int const expected_output[3] = {13, 55, 1234}; int_wrapper actual_output[3] = {-2, -2, -2}; move_only_range wrapped_input{input1}; auto result = move(wrapped_input.begin(), wrapped_input.end(), move_only_range{actual_output}.begin()); From 91700775b09d1a42a7ab3e81699b6f5cc4b81a29 Mon Sep 17 00:00:00 2001 From: Ahana Mukhopadhyay Date: Fri, 12 Jun 2020 13:09:29 -0400 Subject: [PATCH 14/22] updated clang formatting --- .../tests/P0896R4_ranges_alg_fill/test.cpp | 7 +++--- .../tests/P0896R4_ranges_alg_move/test.cpp | 25 +++++++++---------- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/tests/std/tests/P0896R4_ranges_alg_fill/test.cpp b/tests/std/tests/P0896R4_ranges_alg_fill/test.cpp index a9021bcb1f..d8290a3071 100644 --- a/tests/std/tests/P0896R4_ranges_alg_fill/test.cpp +++ b/tests/std/tests/P0896R4_ranges_alg_fill/test.cpp @@ -4,9 +4,9 @@ #include #include #include +#include #include #include -#include constexpr void smoke_test() { using ranges::fill, ranges::iterator_t; @@ -16,7 +16,7 @@ constexpr void smoke_test() { int output2[] = {13, 42, 1367}; { const int value = 7; - auto result = fill(std::begin(output1), std::end(output1), value); + auto result = fill(std::begin(output1), std::end(output1), value); for (int i = 0; i < 3; ++i) { assert(output1[i] == 7); } @@ -24,13 +24,12 @@ constexpr void smoke_test() { } { const int value = 13; - auto result = fill(output2, value); + auto result = fill(output2, value); for (int i = 0; i < 3; ++i) { assert(output2[i] == 13); } assert(result == std::end(output2)); } - } int main() { diff --git a/tests/std/tests/P0896R4_ranges_alg_move/test.cpp b/tests/std/tests/P0896R4_ranges_alg_move/test.cpp index 0e80d08c8d..fcb5f71d3c 100644 --- a/tests/std/tests/P0896R4_ranges_alg_move/test.cpp +++ b/tests/std/tests/P0896R4_ranges_alg_move/test.cpp @@ -4,12 +4,12 @@ #include #include #include +#include #include #include -#include struct int_wrapper { - int val = 10; + int val = 10; constexpr int_wrapper() = default; constexpr int_wrapper(int x) : val{x} {} constexpr int_wrapper(int_wrapper&& that) : val{std::exchange(that.val, -1)} {} @@ -27,16 +27,15 @@ constexpr void smoke_test() { STATIC_ASSERT(same_as, ranges::in_out_result>); // Validate dangling story - STATIC_ASSERT(same_as{}, static_cast(nullptr))), - move_result>); - STATIC_ASSERT(same_as{}, static_cast(nullptr))), - move_result>); + STATIC_ASSERT( + same_as{}, static_cast(nullptr))), move_result>); + STATIC_ASSERT(same_as{}, static_cast(nullptr))), move_result>); int const input[] = {13, 53, 12435}; { int output[] = {-1, -1, -1}; - auto result = move(move_only_range{input}, move_only_range{output}.begin()); - STATIC_ASSERT(same_as>, iterator_t>>>); assert(result.in == move_only_range{input}.end()); assert(result.out == move_only_range{output}.end()); @@ -46,13 +45,14 @@ constexpr void smoke_test() { int output[] = {-1, -1, -1}; move_only_range wrapped_input{input}; auto result = move(wrapped_input.begin(), wrapped_input.end(), move_only_range{output}.begin()); - STATIC_ASSERT(same_as>, iterator_t>>>); + STATIC_ASSERT(same_as>, iterator_t>>>); assert(result.in == wrapped_input.end()); assert(result.out == move_only_range{output}.end()); assert(ranges::equal(output, input)); } { - int_wrapper input1[3] = {13, 55, 1234}; + int_wrapper input1[3] = {13, 55, 1234}; int const expected_output[3] = {13, 55, 1234}; int_wrapper actual_output[3] = {-2, -2, -2}; move_only_range wrapped_input{input1}; @@ -60,11 +60,10 @@ constexpr void smoke_test() { assert(result.in == wrapped_input.end()); assert(result.out == move_only_range{actual_output}.end()); for (int i = 0; i < 3; ++i) { - assert(input1[i].val == -1); - assert(actual_output[i].val == expected_output[i]); + assert(input1[i].val == -1); + assert(actual_output[i].val == expected_output[i]); } } - } int main() { From d4fbaac7c0bca476e79c23a10548e2aa630bc8c3 Mon Sep 17 00:00:00 2001 From: Ahana Mukhopadhyay Date: Thu, 11 Jun 2020 13:35:17 -0400 Subject: [PATCH 15/22] initial fill algo --- stl/inc/algorithm | 4 ++-- tests/std/tests/P0896R4_ranges_alg_fill/test.cpp | 11 ++++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/stl/inc/algorithm b/stl/inc/algorithm index d9815fc2dc..d8c2cf9ed9 100644 --- a/stl/inc/algorithm +++ b/stl/inc/algorithm @@ -2387,7 +2387,7 @@ _FwdIt2 replace_copy_if(_ExPo&&, _FwdIt1 _First, _FwdIt1 _Last, _FwdIt2 _Dest, _ #ifdef __cpp_lib_concepts namespace ranges { - // template + template // VARIABLE ranges::fill class _Fill_fn : private _Not_quite_object { @@ -2411,7 +2411,7 @@ namespace ranges { template _Rng> constexpr borrowed_iterator_t<_Rng> operator()(_Rng&& _Range, const _T& _Value) const { - return (*this)(_RANGES begin(_Range), _RANGES end(_Range), _Value); + return (*this)(_RANGES begin(_Range), _RANGES end(_Range), _Value) } // clang-format on }; diff --git a/tests/std/tests/P0896R4_ranges_alg_fill/test.cpp b/tests/std/tests/P0896R4_ranges_alg_fill/test.cpp index d8290a3071..7104e6987e 100644 --- a/tests/std/tests/P0896R4_ranges_alg_fill/test.cpp +++ b/tests/std/tests/P0896R4_ranges_alg_fill/test.cpp @@ -29,11 +29,20 @@ constexpr void smoke_test() { assert(output2[i] == 13); } assert(result == std::end(output2)); + int output[] = {13, 42, 1367}; + { + const int value = 7; + auto result = fill(output.begin(), output.end(), value); + for (int i = 0; i < 3; ++i) { + assert(output[i] == 7); + } + assert(result == output.end()); } } int main() { STATIC_ASSERT((smoke_test(), true)); + // STATIC_ASSERT((smoke_test(), true)); smoke_test(); } @@ -45,4 +54,4 @@ struct instantiator { } }; -template void test_out(); +template void test_in_out(); From 064684e4fb5a41dd0d9e62d4d46cdbea2b5909cc Mon Sep 17 00:00:00 2001 From: Ahana Mukhopadhyay Date: Tue, 16 Jun 2020 10:40:38 -0400 Subject: [PATCH 16/22] comitting untracked stuff --- stl/inc/algorithm | 79 ++++++++++++++++++++++++++++++++++++++++++++-- tests/std/test.lst | 2 ++ 2 files changed, 79 insertions(+), 2 deletions(-) diff --git a/stl/inc/algorithm b/stl/inc/algorithm index d8c2cf9ed9..af602140c8 100644 --- a/stl/inc/algorithm +++ b/stl/inc/algorithm @@ -2387,7 +2387,6 @@ _FwdIt2 replace_copy_if(_ExPo&&, _FwdIt1 _First, _FwdIt1 _Last, _FwdIt2 _Dest, _ #ifdef __cpp_lib_concepts namespace ranges { - template // VARIABLE ranges::fill class _Fill_fn : private _Not_quite_object { @@ -2411,12 +2410,88 @@ namespace ranges { template _Rng> constexpr borrowed_iterator_t<_Rng> operator()(_Rng&& _Range, const _T& _Value) const { - return (*this)(_RANGES begin(_Range), _RANGES end(_Range), _Value) + return (*this)(_RANGES begin(_Range), _RANGES end(_Range), _Value); } // clang-format on }; inline constexpr _Fill_fn fill{_Not_quite_object::_Construct_tag{}}; + + // VARIABLE ranges::fill_n + class _Fill_n_fn : private _Not_quite_object { + public: + using _Not_quite_object::_Not_quite_object; + + // clang-format off + template _O> + constexpr _O operator()(_O _First, iter_difference_t<_O> _Count, const _T& _Value) const { + auto _UFirst = _Get_unwrapped_n(_STD move(_First), _Count); + for (; _Count > 0; ++_UFirst, --_Count) { + *_UFirst = _Value; + } + + _Seek_wrapped(_First, _STD move(_UFirst)); + return _First; + } + // clang-format on + }; + + inline constexpr _Fill_n_fn fill_n{_Not_quite_object::_Construct_tag{}}; +} // namespace ranges +#endif // __cpp_lib_concepts + +#ifdef __cpp_lib_concepts +namespace ranges { + // VARIABLE ranges::generate + class _Generate_fn : private _Not_quite_object { + public: + using _Not_quite_object::_Not_quite_object; + + // clang-format off + template _S, copy_constructible _F> + requires invocable<_F&> && indirectly_writable<_O, invoke_result_t<_F&>> + constexpr _O operator()(_O _First, _S _Last, _F _Gen) const { + _Adl_verify_range(_First, _Last); + auto _UFirst = _Get_unwrapped(_First); + const auto _ULast = _Get_unwrapped(_Last); + for (; _UFirst != _ULast; ++_UFirst) { + *_UFirst = _Gen(); + } + + _Seek_wrapped(_First, _STD move(_UFirst)); + return _First; + } + + template + requires invocable<_F&> && output_range<_R, invoke_result_t<_F&>> + constexpr borrowed_iterator_t<_R> operator()(_R&& _Range, _F _Gen) const { + return (*this)(_RANGES begin(_Range), _RANGES end(_Range), _Gen); + } + // clang-format on + }; + + inline constexpr _Generate_fn generate{_Not_quite_object::_Construct_tag{}}; + + // VARIABLE ranges::generate_n + class _Generate_n_fn : private _Not_quite_object { + public: + using _Not_quite_object::_Not_quite_object; + + // clang-format off + template + requires invocable<_F&> && indirectly_writable<_O, invoke_result_t<_F&>> + constexpr _O operator()(_O _First, iter_difference_t<_O> _Count, _F _Gen) const { + auto _UFirst = _Get_unwrapped_n(_STD move(_First), _Count); // what if count is larger than num elems + for (; _Count > 0; ++_UFirst, --_Count) { + *_UFirst = _Gen(); + } + + _Seek_wrapped(_First, _STD move(_UFirst)); + return _First; + } + } + + inline constexpr _Generate_n_fn generate_n{_Not_quite_object::_Construct_tag{}}; } // namespace ranges #endif // __cpp_lib_concepts diff --git a/tests/std/test.lst b/tests/std/test.lst index d9ab9d6ee7..d5c04757a8 100644 --- a/tests/std/test.lst +++ b/tests/std/test.lst @@ -242,6 +242,7 @@ tests\P0896R4_ranges_alg_count tests\P0896R4_ranges_alg_count_if tests\P0896R4_ranges_alg_equal tests\P0896R4_ranges_alg_fill +tests\P0896R4_ranges_alg_fill_n tests\P0896R4_ranges_alg_find tests\P0896R4_ranges_alg_find_end tests\P0896R4_ranges_alg_find_first_of @@ -249,6 +250,7 @@ tests\P0896R4_ranges_alg_find_if tests\P0896R4_ranges_alg_find_if_not tests\P0896R4_ranges_alg_for_each tests\P0896R4_ranges_alg_for_each_n +tests\P0896R4_ranges_alg_generate tests\P0896R4_ranges_alg_mismatch tests\P0896R4_ranges_alg_move tests\P0896R4_ranges_alg_none_of From 3f8fb497a6677e3b39c34ca62f35df7394a7c38c Mon Sep 17 00:00:00 2001 From: Ahana Mukhopadhyay Date: Tue, 16 Jun 2020 12:52:32 -0400 Subject: [PATCH 17/22] cleaned up branch for move algo --- stl/inc/algorithm | 110 --------------------------------------------- tests/std/test.lst | 3 -- 2 files changed, 113 deletions(-) diff --git a/stl/inc/algorithm b/stl/inc/algorithm index af602140c8..de7bba8c41 100644 --- a/stl/inc/algorithm +++ b/stl/inc/algorithm @@ -2385,116 +2385,6 @@ _FwdIt2 replace_copy_if(_ExPo&&, _FwdIt1 _First, _FwdIt1 _Last, _FwdIt2 _Dest, _ } #endif // _HAS_CXX17 -#ifdef __cpp_lib_concepts -namespace ranges { - - // VARIABLE ranges::fill - class _Fill_fn : private _Not_quite_object { - public: - using _Not_quite_object::_Not_quite_object; - - // clang-format off - template _O, sentinel_for<_O> _S> - constexpr _O operator()(_O _First, _S _Last, const _T& _Value) const { - _Adl_verify_range(_First, _Last); - auto _UFirst = _Get_unwrapped(_STD move(_First)); - auto _ULast = _Get_unwrapped(_STD move(_Last)); - while (_UFirst != _ULast) { - *_UFirst = _Value; - ++_UFirst; - } - - _Seek_wrapped(_First, _STD move(_UFirst)); - return _First; - } - - template _Rng> - constexpr borrowed_iterator_t<_Rng> operator()(_Rng&& _Range, const _T& _Value) const { - return (*this)(_RANGES begin(_Range), _RANGES end(_Range), _Value); - } - // clang-format on - }; - - inline constexpr _Fill_fn fill{_Not_quite_object::_Construct_tag{}}; - - // VARIABLE ranges::fill_n - class _Fill_n_fn : private _Not_quite_object { - public: - using _Not_quite_object::_Not_quite_object; - - // clang-format off - template _O> - constexpr _O operator()(_O _First, iter_difference_t<_O> _Count, const _T& _Value) const { - auto _UFirst = _Get_unwrapped_n(_STD move(_First), _Count); - for (; _Count > 0; ++_UFirst, --_Count) { - *_UFirst = _Value; - } - - _Seek_wrapped(_First, _STD move(_UFirst)); - return _First; - } - // clang-format on - }; - - inline constexpr _Fill_n_fn fill_n{_Not_quite_object::_Construct_tag{}}; -} // namespace ranges -#endif // __cpp_lib_concepts - -#ifdef __cpp_lib_concepts -namespace ranges { - // VARIABLE ranges::generate - class _Generate_fn : private _Not_quite_object { - public: - using _Not_quite_object::_Not_quite_object; - - // clang-format off - template _S, copy_constructible _F> - requires invocable<_F&> && indirectly_writable<_O, invoke_result_t<_F&>> - constexpr _O operator()(_O _First, _S _Last, _F _Gen) const { - _Adl_verify_range(_First, _Last); - auto _UFirst = _Get_unwrapped(_First); - const auto _ULast = _Get_unwrapped(_Last); - for (; _UFirst != _ULast; ++_UFirst) { - *_UFirst = _Gen(); - } - - _Seek_wrapped(_First, _STD move(_UFirst)); - return _First; - } - - template - requires invocable<_F&> && output_range<_R, invoke_result_t<_F&>> - constexpr borrowed_iterator_t<_R> operator()(_R&& _Range, _F _Gen) const { - return (*this)(_RANGES begin(_Range), _RANGES end(_Range), _Gen); - } - // clang-format on - }; - - inline constexpr _Generate_fn generate{_Not_quite_object::_Construct_tag{}}; - - // VARIABLE ranges::generate_n - class _Generate_n_fn : private _Not_quite_object { - public: - using _Not_quite_object::_Not_quite_object; - - // clang-format off - template - requires invocable<_F&> && indirectly_writable<_O, invoke_result_t<_F&>> - constexpr _O operator()(_O _First, iter_difference_t<_O> _Count, _F _Gen) const { - auto _UFirst = _Get_unwrapped_n(_STD move(_First), _Count); // what if count is larger than num elems - for (; _Count > 0; ++_UFirst, --_Count) { - *_UFirst = _Gen(); - } - - _Seek_wrapped(_First, _STD move(_UFirst)); - return _First; - } - } - - inline constexpr _Generate_n_fn generate_n{_Not_quite_object::_Construct_tag{}}; -} // namespace ranges -#endif // __cpp_lib_concepts - // FUNCTION TEMPLATE generate template _CONSTEXPR20 void generate(_FwdIt _First, _FwdIt _Last, _Fn _Func) { // replace [_First, _Last) with _Func() diff --git a/tests/std/test.lst b/tests/std/test.lst index d5c04757a8..1ac2abf208 100644 --- a/tests/std/test.lst +++ b/tests/std/test.lst @@ -241,8 +241,6 @@ tests\P0896R4_ranges_alg_copy_n tests\P0896R4_ranges_alg_count tests\P0896R4_ranges_alg_count_if tests\P0896R4_ranges_alg_equal -tests\P0896R4_ranges_alg_fill -tests\P0896R4_ranges_alg_fill_n tests\P0896R4_ranges_alg_find tests\P0896R4_ranges_alg_find_end tests\P0896R4_ranges_alg_find_first_of @@ -250,7 +248,6 @@ tests\P0896R4_ranges_alg_find_if tests\P0896R4_ranges_alg_find_if_not tests\P0896R4_ranges_alg_for_each tests\P0896R4_ranges_alg_for_each_n -tests\P0896R4_ranges_alg_generate tests\P0896R4_ranges_alg_mismatch tests\P0896R4_ranges_alg_move tests\P0896R4_ranges_alg_none_of From 3991e3468ee628064d9bc4ee92ef276c1a664ae0 Mon Sep 17 00:00:00 2001 From: Ahana Mukhopadhyay Date: Tue, 16 Jun 2020 13:47:35 -0400 Subject: [PATCH 18/22] removed fill files --- .../std/tests/P0896R4_ranges_alg_fill/env.lst | 4 -- .../tests/P0896R4_ranges_alg_fill/test.cpp | 57 ------------------- 2 files changed, 61 deletions(-) delete mode 100644 tests/std/tests/P0896R4_ranges_alg_fill/env.lst delete mode 100644 tests/std/tests/P0896R4_ranges_alg_fill/test.cpp diff --git a/tests/std/tests/P0896R4_ranges_alg_fill/env.lst b/tests/std/tests/P0896R4_ranges_alg_fill/env.lst deleted file mode 100644 index f3ccc8613c..0000000000 --- a/tests/std/tests/P0896R4_ranges_alg_fill/env.lst +++ /dev/null @@ -1,4 +0,0 @@ -# Copyright (c) Microsoft Corporation. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -RUNALL_INCLUDE ..\concepts_matrix.lst diff --git a/tests/std/tests/P0896R4_ranges_alg_fill/test.cpp b/tests/std/tests/P0896R4_ranges_alg_fill/test.cpp deleted file mode 100644 index 7104e6987e..0000000000 --- a/tests/std/tests/P0896R4_ranges_alg_fill/test.cpp +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -#include -#include -#include -#include -#include -#include - -constexpr void smoke_test() { - using ranges::fill, ranges::iterator_t; - using std::same_as; - - int output1[] = {13, 42, 1367}; - int output2[] = {13, 42, 1367}; - { - const int value = 7; - auto result = fill(std::begin(output1), std::end(output1), value); - for (int i = 0; i < 3; ++i) { - assert(output1[i] == 7); - } - assert(result == std::end(output1)); - } - { - const int value = 13; - auto result = fill(output2, value); - for (int i = 0; i < 3; ++i) { - assert(output2[i] == 13); - } - assert(result == std::end(output2)); - int output[] = {13, 42, 1367}; - { - const int value = 7; - auto result = fill(output.begin(), output.end(), value); - for (int i = 0; i < 3; ++i) { - assert(output[i] == 7); - } - assert(result == output.end()); - } -} - -int main() { - STATIC_ASSERT((smoke_test(), true)); - // STATIC_ASSERT((smoke_test(), true)); - smoke_test(); -} - -struct instantiator { - template - static void call(Out&& out = {}) { - (void) ranges::fill(out, 42); - (void) ranges::fill(ranges::begin(out), ranges::end(out), 42); - } -}; - -template void test_in_out(); From 558258772a460ea6f42f7adc210182ba7a562d02 Mon Sep 17 00:00:00 2001 From: Ahana Mukhopadhyay Date: Tue, 16 Jun 2020 13:53:20 -0400 Subject: [PATCH 19/22] formatting update --- stl/inc/algorithm | 2 -- 1 file changed, 2 deletions(-) diff --git a/stl/inc/algorithm b/stl/inc/algorithm index de7bba8c41..d29ad8c576 100644 --- a/stl/inc/algorithm +++ b/stl/inc/algorithm @@ -1260,9 +1260,7 @@ namespace ranges { }; inline constexpr _Copy_if_fn copy_if{_Not_quite_object::_Construct_tag{}}; -} // namespace ranges -namespace ranges { // ALIAS TEMPLATE move_result template using move_result = in_out_result<_In, _Out>; From 492a007b8fe7507c01d7587319cf6c38e6eda7ef Mon Sep 17 00:00:00 2001 From: Casey Carter Date: Tue, 16 Jun 2020 11:32:09 -0700 Subject: [PATCH 20/22] Fix what Casey broke in the test_range PR --- tests/std/include/range_algorithm_support.hpp | 5 +++-- tests/std/tests/P0896R4_ranges_alg_move/test.cpp | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/std/include/range_algorithm_support.hpp b/tests/std/include/range_algorithm_support.hpp index 6a1ecd931c..b06fe174c4 100644 --- a/tests/std/include/range_algorithm_support.hpp +++ b/tests/std/include/range_algorithm_support.hpp @@ -255,8 +255,9 @@ namespace test { ++ptr_; } - [[nodiscard]] constexpr friend std::remove_cv_t iter_move(iterator const& i) requires at_least { - return ranges::iter_move(i.ptr_); + [[nodiscard]] constexpr friend std::remove_cv_t iter_move(iterator const& i) + requires at_least && std::constructible_from, Element> { + return std::move(*i.ptr_); } constexpr friend void iter_swap(iterator const& x, iterator const& y) requires at_least { diff --git a/tests/std/tests/P0896R4_ranges_alg_move/test.cpp b/tests/std/tests/P0896R4_ranges_alg_move/test.cpp index fcb5f71d3c..13bf7a15a2 100644 --- a/tests/std/tests/P0896R4_ranges_alg_move/test.cpp +++ b/tests/std/tests/P0896R4_ranges_alg_move/test.cpp @@ -79,4 +79,4 @@ struct instantiator { } }; -template void test_in_out(); +template void test_in_write(); From 7a899e5bf6c1ce1f50c84c6684eff103c778ef82 Mon Sep 17 00:00:00 2001 From: Casey Carter Date: Tue, 16 Jun 2020 12:11:27 -0700 Subject: [PATCH 21/22] Trim trailing whitespace --- stl/inc/algorithm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stl/inc/algorithm b/stl/inc/algorithm index d29ad8c576..e6dcc5d6d8 100644 --- a/stl/inc/algorithm +++ b/stl/inc/algorithm @@ -1272,7 +1272,7 @@ namespace ranges { // clang-format off template _Se, weakly_incrementable _Out> - requires indirectly_movable<_It, _Out> + requires indirectly_movable<_It, _Out> constexpr move_result<_It, _Out> operator()(_It _First, _Se _Last, _Out _Result) const { _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_STD move(_First)); @@ -1286,7 +1286,7 @@ namespace ranges { } template - requires indirectly_movable, _Out> + requires indirectly_movable, _Out> constexpr move_result, _Out> operator()(_Rng&& _Range, _Out _Result) const { return (*this)(_RANGES begin(_Range), _RANGES end(_Range), _STD move(_Result)); From 4ffc678b7e332d99f960ba31638d07922265d6d6 Mon Sep 17 00:00:00 2001 From: Ahana Mukhopadhyay Date: Wed, 17 Jun 2020 14:35:50 -0400 Subject: [PATCH 22/22] minor updates --- stl/inc/algorithm | 3 +-- tests/std/tests/P0896R4_ranges_alg_move/test.cpp | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/stl/inc/algorithm b/stl/inc/algorithm index e6dcc5d6d8..76b42912fc 100644 --- a/stl/inc/algorithm +++ b/stl/inc/algorithm @@ -1287,8 +1287,7 @@ namespace ranges { template requires indirectly_movable, _Out> - constexpr move_result, _Out> - operator()(_Rng&& _Range, _Out _Result) const { + constexpr move_result, _Out> operator()(_Rng&& _Range, _Out _Result) const { return (*this)(_RANGES begin(_Range), _RANGES end(_Range), _STD move(_Result)); } // clang-format on diff --git a/tests/std/tests/P0896R4_ranges_alg_move/test.cpp b/tests/std/tests/P0896R4_ranges_alg_move/test.cpp index 13bf7a15a2..d87ad42661 100644 --- a/tests/std/tests/P0896R4_ranges_alg_move/test.cpp +++ b/tests/std/tests/P0896R4_ranges_alg_move/test.cpp @@ -33,7 +33,7 @@ constexpr void smoke_test() { int const input[] = {13, 53, 12435}; { - int output[] = {-1, -1, -1}; + int output[] = {-2, -2, -2}; auto result = move(move_only_range{input}, move_only_range{output}.begin()); STATIC_ASSERT(same_as>, iterator_t>>>); @@ -42,7 +42,7 @@ constexpr void smoke_test() { assert(ranges::equal(output, input)); } { - int output[] = {-1, -1, -1}; + int output[] = {-2, -2, -2}; move_only_range wrapped_input{input}; auto result = move(wrapped_input.begin(), wrapped_input.end(), move_only_range{output}.begin()); STATIC_ASSERT(same_as