Failing to create a std::ranges::iota_view with value and bound
I tried to create a std::ranges::iota_view with a value and a bound:
C++ vector: for loop to std::transform
I got a code in the following form
Typed view possible? Or am I thinking about it wrong
this is not a specific bug but a general C++ design question. Consider the following scenario:
Adapt an existing range type to be c++20 ranges compatible without changing it
My objective is to take some of the Unreal Engine types and make them possible to use with c++20 ranges. I started with TArray
I figured it would be the easiest. It is essentailly a std::vector
, stored contiguously etc. So in all it can easily be represented with this:
a more explicit type instead of auto for std::ranges::views result
auto
is really nice to maintain a single definition and avoid some typing. It’s also necessary for std::ranges::views
. However, auto
can make code harder to read it’s too far from the defining type (particularly in code review). Replacing it with an explicit type can also validate that the type is what you expect (e.g. before passing it to a templated function and winding up in a world of template error message hurt). There needs to be a balance. Unfortunately, auto
is necessary for views
(I assume since the type is implementation dependent).
How to make `std::from_range` move the elements when it makes sense?
Consider this code:
Why are views required to be (move-)assignable?
The std::ranges::view
concept in C++23 requires a view to be movable, which includes move-assignability. I understand why we want a view to be move-constructible, but why is the assignment necessary?