How to write a concept that will describe the types the Range-based for loop is enabled for?
One attempt is:
template < typename Range > concept bool RRange
= requires(Range range) {{std::begin(range),std::end(range)};};
but what I really want is some thing like this:
template < typename Range > concept bool RRange
= requires(Range range) {{for(auto&& item : range);};}; // compile error
that is, RRange
to be the concept of all types the expression for(auto&& item : range);
is valid for. What is the best way to achieve this?
I am using GCC7 snapshot with g++ -std=c++1z -fconcepts
.
According to P0587, this should suffice:
Here's what I came up with while reviewing [stmt.ranged].
And the test cases.