summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/template/pr61745.C
blob: 0f7c280e52ae6ddd2dfde5c7ca96381a93ccc992 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// PR c++/61745

template <typename INT,INT P> class Zp;

template <typename INT,INT P> 
Zp<INT,P> operator-(const Zp<INT,P>& a, const Zp<INT,P>& b);

template <typename INT,INT P>
class Zp {
public:
  static const INT p = P;
private:
  INT val;
public:
  Zp() : val(0) {}
  Zp( INT x ) : val(x%p) { if (x < 0 ) x+= p; }

  // this compiles only if the following definition is moved
  // AFTER the friend declaration
  Zp  operator-() const { return Zp(p-val); }
  friend Zp<INT,P> operator- <>(const Zp<INT,P>& a, const Zp<INT,P>& b); // { dg-error "declaration|expected" }
};