-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Implement ranges::replace_copy #985
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| Read wrapped_input{input}; | ||
|
|
||
| auto result = | ||
| replace_copy(wrapped_input.begin(), wrapped_input.end(), Write{output}, 47, P{47, 1}, get_second); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The compiler error is:
C:\agent\_work\1\s\tests\std\tests\P0896R4_ranges_alg_replace_copy\test.cpp(35,17): error: no matching function for call to object of type 'const std::ranges::_Replace_copy_fn'
replace_copy(wrapped_input.begin(), wrapped_input.end(), Write{output}, 47, P{47, 1}, get_second);
^~~~~~~~~~~~
C:/agent/_work/1/s/tests/std/include\range_algorithm_support.hpp(603,32): note: in instantiation of function template specialization 'instantiator::call<test::range<std::input_iterator_tag, const std::pair<int, int>, test::Sized::no, test::CanDifference::no, test::Common::no, test::CanCompare::no, test::ProxyRef::no>, test::iterator<std::input_iterator_tag, std::pair<int, int>, test::CanDifference::no, test::CanCompare::no, test::ProxyRef::no, test::IsWrapped::yes> >' requested here
Continuation::template call<Args...,
^
C:/agent/_work/1/s/tests/std/include\range_algorithm_support.hpp(770,32): note: in instantiation of function template specialization 'with_writable_iterators<instantiator, std::pair<int, int> >::call<test::range<std::input_iterator_tag, const std::pair<int, int>, test::Sized::no, test::CanDifference::no, test::Common::no, test::CanCompare::no, test::ProxyRef::no> >' requested here
Continuation::template call<Args...,
^
C:/agent/_work/1/s/tests/std/include\range_algorithm_support.hpp(945,83): note: in instantiation of function template specialization 'with_input_ranges<with_writable_iterators<instantiator, std::pair<int, int> >, const std::pair<int, int> >::call<>' requested here
with_input_ranges<with_writable_iterators<Instantiator, Element2>, Element1>::call();
^
C:\agent\_work\1\s\tests\std\tests\P0896R4_ranges_alg_replace_copy\test.cpp(55,20): note: in instantiation of function template specialization 'test_in_write<instantiator, const std::pair<int, int>, std::pair<int, int> >' requested here
STATIC_ASSERT((test_in_write<instantiator, P const, P>(), true));
^
D:\build\x64\out\inc\algorithm(3080,50): note: candidate template ignored: constraints not satisfied [with _It = test::iterator<std::input_iterator_tag, const std::pair<int, int>, test::CanDifference::no, test::CanCompare::no, test::ProxyRef::no, test::IsWrapped::yes>, _Se = test::sentinel<const std::pair<int, int>, test::IsWrapped::yes>, _Ty1 = int, _Ty2 = std::pair<int, int>, _Out = test::iterator<std::input_iterator_tag, std::pair<int, int>, test::CanDifference::no, test::CanCompare::no, test::ProxyRef::no, test::IsWrapped::yes>, _Pj = get_nth_fn<1>]
constexpr replace_copy_result<_It, _Out> operator()(
^
D:\build\x64\out\inc\algorithm(3076,86): note: because 'output_iterator<test::iterator<std::input_iterator_tag, std::pair<int, int>, test::CanDifference::no, test::CanCompare::no, test::ProxyRef::no, test::IsWrapped::yes>, const std::pair<int, int> &>' evaluated to false
template <input_iterator _It, sentinel_for<_It> _Se, class _Ty1, class _Ty2, output_iterator<const _Ty2&> _Out,
^
D:\build\x64\out\inc\xutility(844,9): note: because '*__i++ = static_cast<_Ty &&>(__t)' would be invalid: indirection requires pointer operand ('void' invalid)
*__i++ = static_cast<_Ty&&>(__t);
^
The template machinery here is almost beyond my comprehension, but I observe that (1) your test differs from the other tests currently using test_in_write in that its instantiator actually verifies the indirectly_writable concept, and (2) with_writable_iterators appears to pass iterator<input, MEOW> which doesn't seem correct:
STL/tests/std/include/range_algorithm_support.hpp
Lines 603 to 606 in 5be7d49
| Continuation::template call<Args..., | |
| iterator<input, Element, CanDifference::no, CanCompare::no, ProxyRef::no>>(); | |
| Continuation::template call<Args..., | |
| iterator<input, Element, CanDifference::no, CanCompare::no, ProxyRef::yes>>(); |
I'm not sure if this analysis is correct.
5a09b11 to
56a320c
Compare
|
I am wondering whether the @CaseyCarter can you remember why these two (and the remove_copy_*) are different? |
|
Dropping in favor of #983 |
This implements ranges_copy. There is some bug my brain autocorrect away. Will look at it later in the evening