Fix postfix operator++ operation
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@8255 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
65d72f73cd
commit
e364bc65e1
1 changed files with 4 additions and 5 deletions
|
|
@ -63,7 +63,6 @@ see bottom for a set of possible tests
|
|||
class Op{
|
||||
public:
|
||||
int i;
|
||||
int j;
|
||||
Op(int a=0):i(a)
|
||||
{}
|
||||
Op(const Op& o):i(o.i)
|
||||
|
|
@ -109,10 +108,10 @@ public:
|
|||
int operator()(int a,int b){return i+a+b;}
|
||||
|
||||
// increment/decrement operators
|
||||
Op& operator++(){++i; return *this;} // prefix ++
|
||||
Op operator++(int){return Op(i++);} // postfix ++
|
||||
Op& operator--(){--i; return *this;} // prefix --
|
||||
Op operator--(int){return Op(i++);} // postfix --
|
||||
Op& operator++() {++i; return *this;} // prefix ++
|
||||
Op operator++(int) {Op o = *this; ++(*this); return o;} // postfix ++
|
||||
Op& operator--() {--i; return *this;} // prefix --
|
||||
Op operator--(int) {Op o = *this; --(*this); return o;} // postfix --
|
||||
|
||||
// TODO: <<,<<=
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue