Permalink
Browse files

Merge pull request #9 from Zapeth/master

Fix BitField postfix in/decrement operators
  • Loading branch information...
2 parents 74cfa6d + eef92af commit 41ac9c73dfa32e2fbc0af6668358092fafdfcae4 @preshing committed on GitHub Jul 7, 2016
Showing with 24 additions and 4 deletions.
  1. +24 −4 common/bitfield.h
View
@@ -54,9 +54,19 @@ struct BitFieldMember
}
BitFieldMember& operator++() { return *this += 1; }
- BitFieldMember& operator++(int) { return *this += 1; } // postfix form
+ BitFieldMember operator++(int) // postfix form
+ {
+ BitFieldMember tmp(*this);
+ operator++();
+ return tmp;
+ }
BitFieldMember& operator--() { return *this -= 1; }
- BitFieldMember& operator--(int) { return *this -= 1; } // postfix form
+ BitFieldMember operator--(int) // postfix form
+ {
+ BitFieldMember tmp(*this);
+ operator--();
+ return tmp;
+ }
};
@@ -114,9 +124,19 @@ struct BitFieldArray
}
Element& operator++() { return *this += 1; }
- Element& operator++(int) { return *this += 1; } // postfix form
+ Element operator++(int) // postfix form
+ {
+ Element tmp(*this);
+ operator++();
+ return tmp;
+ }
Element& operator--() { return *this -= 1; }
- Element& operator--(int) { return *this -= 1; } // postfix form
+ Element operator--(int) // postfix form
+ {
+ Element tmp(*this);
+ operator--();
+ return tmp;
+ }
};
Element operator[](int i)

0 comments on commit 41ac9c7

Please sign in to comment.