I want to write a function template that accepts ranges of MyType-typed values, so I wrote
void f(const std::ranges::range auto& my_range) { /* ... */ }
Unfortunately this does not constrain the type of the values contained in the range. I could use a requires clause before the function body block but I want something reusable and not specific to this function.
Naturally I wrote
template <class T, class V>
concept range_of = std::ranges::range<T> && std::is_same_v<V, std::ranges::range_value_t<T>>;
void f(const range_of<MyType> auto& my_range) { /* ... */ }
but I'm very surprised that this is not supported out-of-the-box by the standard library given how natural it seems. This also applies to std::ranges::view for which I could write a similar view_of concept.
Is my definition of range_of incomplete or wrong? Or is there a good reason this isn't offered by the standard library?