| 1 |
// NB comments CA107/US117 |
| 2 |
// { dg-do compile { target concepts } } |
| 3 |
|
| 4 |
template <unsigned N> constexpr bool Atomic = true; |
| 5 |
template <unsigned N> concept C = Atomic<N>; |
| 6 |
template <unsigned N> concept Add1 = C<N + 1>; |
| 7 |
template <unsigned N> concept AddOne = C<N + 1>; |
| 8 |
template <unsigned M> void f() |
| 9 |
requires Add1<2 * M>; |
| 10 |
template <unsigned M> int f() |
| 11 |
requires AddOne<2 * M> && true; |
| 12 |
|
| 13 |
int x = f<0>(); // OK, the atomic constraints from concept C in both fs are Atomic<N> |
| 14 |
// with mapping similar to N -> 2 * M + 1 |
| 15 |
|
| 16 |
template <unsigned N> struct WrapN; |
| 17 |
template <unsigned N> using Add1Ty = WrapN<N + 1>; |
| 18 |
template <unsigned N> using AddOneTy = WrapN<N + 1>; |
| 19 |
template <unsigned M> void g(Add1Ty<2 * M> *); |
| 20 |
template <unsigned M> void g(AddOneTy<2 * M> *); |
| 21 |
|
| 22 |
void h() { |
| 23 |
g<0>(nullptr); // OK, there is only one g |
| 24 |
} |
| 25 |
template <unsigned N> void f2() |
| 26 |
requires Add1<2 * N>; |
| 27 |
template <unsigned N> int f2() |
| 28 |
requires Add1<N * 2> && true; |
| 29 |
void h2() { |
| 30 |
f2<0>(); // { dg-error "ambiguous" } ill-formed, no diagnostic required: |
| 31 |
// required determination of subsumption between atomic constraints that are |
| 32 |
// functionally equivalent but not equivalent |
| 33 |
} |