re PR c++/61745 (template friend for dyadic operator- is only accepted if the monadic operator- follows it)
2014-09-18 Paolo Carlini <paolo.carlini@oracle.com> PR c++/61745 * g++.dg/template/pr61745.C: New. From-SVN: r215345
This commit is contained in:
parent
1d2af9939b
commit
2a2c9357f6
2 changed files with 27 additions and 0 deletions
|
@ -1,3 +1,8 @@
|
|||
2014-09-18 Paolo Carlini <paolo.carlini@oracle.com>
|
||||
|
||||
PR c++/61745
|
||||
* g++.dg/template/pr61745.C: New.
|
||||
|
||||
2014-09-17 Marek Polacek <polacek@redhat.com>
|
||||
|
||||
PR c/61854
|
||||
|
|
22
gcc/testsuite/g++.dg/template/pr61745.C
Normal file
22
gcc/testsuite/g++.dg/template/pr61745.C
Normal file
|
@ -0,0 +1,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" }
|
||||
};
|
Loading…
Add table
Reference in a new issue