I want to write a range adapter called progress_view which can wrap any other sized range. It should provide iterators which wrap the wrapped range's iterators, except for the fact that incrementing them calls an internal function to increment a progress object of some sort. The idea is that you should be able to wrap a range-based for loop operand in this progress_view.
for (auto& x : progress_view(my_range, my_progress)); // minimum viable product
for (auto& x : my_range | progress_view(my_progress)); // ideally supporting something like this as well?
The resulting progress_view should be an input_range only, I think. I am not sure what other std::ranges properties it should meet.
I am not understanding the idiomatic and way to implement this while handling temporaries correctly. My first idea was to store a reference/pointer to the wrapped range, but this is no good for temporaries in for loops, right? I could also std::move into the adapter, but this seems a bit clunky. Also, what if the passed range is a temporary but is a view, so taking it by value would be fine? Also also, how should I support pipelining? Is it as straightforward as an overloading with forwarding into a constructor?
Would appreciate any tips in how something like this should be handled! Thank you.