More idiomatic signature for operator=()

Return a reference instead of void so to enable
chained assignments like

"p = q = Position(...);"

Suggested by Rein Halbersma.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
Marco Costalba
2012-07-05 11:52:11 +01:00
parent 7d2530873e
commit 775488340e
4 changed files with 9 additions and 5 deletions
+3 -1
View File
@@ -89,7 +89,7 @@ CheckInfo::CheckInfo(const Position& pos) {
/// object do not depend on any external data so we detach state pointer from
/// the source one.
void Position::operator=(const Position& pos) {
Position& Position::operator=(const Position& pos) {
memcpy(this, &pos, sizeof(Position));
startState = *st;
@@ -97,6 +97,8 @@ void Position::operator=(const Position& pos) {
nodes = 0;
assert(pos_is_ok());
return *this;
}