| 1 |
// PR c++/61745 |
| 2 |
|
| 3 |
template <typename INT,INT P> class Zp; |
| 4 |
|
| 5 |
template <typename INT,INT P> |
| 6 |
Zp<INT,P> operator-(const Zp<INT,P>& a, const Zp<INT,P>& b); |
| 7 |
|
| 8 |
template <typename INT,INT P> |
| 9 |
class Zp { |
| 10 |
public: |
| 11 |
static const INT p = P; |
| 12 |
private: |
| 13 |
INT val; |
| 14 |
public: |
| 15 |
Zp() : val(0) {} |
| 16 |
Zp( INT x ) : val(x%p) { if (x < 0 ) x+= p; } |
| 17 |
|
| 18 |
// this compiles only if the following definition is moved |
| 19 |
// AFTER the friend declaration |
| 20 |
Zp operator-() const { return Zp(p-val); } |
| 21 |
// In C++2A, we have an unqualified-id (operator-) followed by |
| 22 |
// '<', and name lookup found a function. |
| 23 |
friend Zp<INT,P> operator- <>(const Zp<INT,P>& a, const Zp<INT,P>& b); // { dg-error "20:declaration of .operator\\-. as non-function" "" { target c++17_down } } |
| 24 |
// { dg-error "expected" "" { target c++17_down } .-1 } |
| 25 |
}; |