concept bool Example_concept = requires (T t) {
typename T::A;
requires requires (T t, typename T::A a) {
{ t + a } -> T;
};
};
```
From the type T, which is directly constrained by the requirement, we first have the type requirement on the existence of the type T::A. However, when there are other requirements on T::A in connection with T, it seems to be not possible to introduce another local parameter inside requirement-body, after the the requirement-parameter-list is closed. So we have the code above, which seem to work in the latest version of g++. However, although the nested requires-expression solves the problem of introducing new local parameters, the local parameters in the outer requirement expression are all lost, hence have to be repeated in the requirement-parameter-list of the nested. Could anyone help me if there are better ways this kind of constraint can be specified? I was thinking it might be convenient if local parameters can be introduced in type requirements [expr.prim.req.type], enabling something like,
concept bool Example_concept = requires (T t) {
typename T::A (some syntax containing a, like just a);
{ t + a } -> T;
};
```
Or maybe if nested requires-expression could capture the local parameters in the nesting requires-expression, something like,
concept bool Example_concept = requires (T t) {
typename T::A;
requires requires (typename T::A a) {
{ t + a } -> T;
};
};
```
could be equally nice. Any help with plans or comments about feature of this style, or suggestions of better alternatives about this problem will be deeply appreciated.
Hi everybody on this group,I am recently experimenting concepts within a non-trivial project and run into some problems with complex requirement on types constructed from the type constrained by the concept. For instance, in the following minimized example,```template<typename T>concept bool Example_concept = requires (T t) {
typename T::A;
requires requires (T t, typename T::A a) {
{ t + a } -> T;
};
};
```
concept bool Example_concept =
requires { typename T::A; }
&& requires (T t, typename T::A a) {
{ t + a } -> T;
};
```
which is semantically equivalent to:
concept bool Example_concept =
requires (T t, typename T::A a) {
{ t + a } -> T;
};
```