]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/testsuite/g++.dg/template/pr61745.C
/cp
[thirdparty/gcc.git] / gcc / testsuite / g++.dg / template / pr61745.C
CommitLineData
7b42f565 1// PR c++/61745
2
3template <typename INT,INT P> class Zp;
4
5template <typename INT,INT P>
6Zp<INT,P> operator-(const Zp<INT,P>& a, const Zp<INT,P>& b);
7
8template <typename INT,INT P>
9class Zp {
10public:
11 static const INT p = P;
12private:
13 INT val;
14public:
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); }
8110e96e 21 // In C++2A, we have an unqualified-id (operator-) followed by
22 // '<', and name lookup found a function.
43bbc1da 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 }
7b42f565 25};