One of the corners of C++20 concepts is that there are certain situations in which you have to write requires requires
. For instance, this example from [expr.prim.req]/3:
A requires-expression can also be used in a requires-clause ([temp]) as a way of writing ad hoc constraints on template arguments such as the one below:
template<typename T> requires requires (T x) { x + x; } T add(T a, T b) { return a + b; }
The first requires introduces the requires-clause, and the second introduces the requires-expression.
What is the technical reason behind needing that second requires
keyword? Why can’t we just allow writing:
template<typename T>
requires (T x) { x + x; }
T add(T a, T b) { return a + b; }
(Note: please don’t answer that the grammar requires
it)