-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Labels
bugSomething isn't workingSomething isn't workingfixedSomething works now, yay!Something works now, yay!rangesC++20/23 rangesC++20/23 ranges
Description
Describe the bug
I need to transform a range and copy the results to an array.
I am using copy_at helper which calls std::copy.
This does not compile since version 17.4.
Now I need to use std::ranges::copy instead.
template <typename Range1, typename Range2>
constexpr void copy_at(Range1 & r1, const Range2 & r2)
{
//std::copy(std::begin(r2), std::end(r2), std::begin(r1)); //does not compile
std::ranges::copy(r2, std::begin(r1)); //compiles
}
struct A
{
int getInt() const { return 1; }
};
int main()
{
std::array<A, 10> a_range;
std::array<int, 10> int_range;
copy_at(int_range, a_range | std::ranges::views::transform([](const A & a) { return a.getInt(); }));
}
Expected behavior
std::copy used to work when copying a view to an array.
However since version 17.4 only the std::ranges::copy call compiles.
The std::copy call produces an error here:
template <class _Iter, class _UIter>
constexpr void _Seek_wrapped(_Iter& _It, _UIter&& _UIt) {
if constexpr (_Wrapped_seekable_v<_Iter, _UIter>) {
_It._Seek_to(_STD forward<_UIter>(_UIt));
} else {
_It = _STD forward<_UIter>(_UIt); //<---- this triggers the error
}
}
STL version
Microsoft Visual Studio Community 2022 (64-bit) - Current
Version 17.4.0
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingfixedSomething works now, yay!Something works now, yay!rangesC++20/23 rangesC++20/23 ranges