if I take for example the ranges::fill algorithm:
https://en.cppreference.com/w/cpp/algorithm/ranges/fill
the signature is:
template< class T, ranges::output_range<const T&> R >
constexpr ranges::borrowed_iterator_t<R> fill( R&& r, const T& value );
And an example use:
#include <algorithm>
#include <vector>
#include <iostream>
int main()
{
std::vector<int> v{0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
namespace ranges = std::ranges;
ranges::fill(v, 10);
}
Why does ranges::fill take a rvalue reference as argument ( R&& r) ? I would have expected it to take a lvalue reference ( R& r) instead.