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>
/// object do not depend on any external data so we detach state pointer from
/// the source one.
/// 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;
memcpy(this, &pos, sizeof(Position));
startState = *st;
nodes = 0;
assert(pos_is_ok());
nodes = 0;
assert(pos_is_ok());
Position(const Position& p) { *this = p; }
Position(const Position& p, Thread* t) { *this = p; thisThread = t; }
Position(const std::string& f, bool c960, Thread* t) { from_fen(f, c960, t); }
Position(const Position& p) { *this = p; }
Position(const Position& p, Thread* t) { *this = p; thisThread = t; }
Position(const std::string& f, bool c960, Thread* t) { from_fen(f, c960, t); }
- void operator=(const Position&);
+ Position& operator=(const Position&);
// Text input/output
void from_fen(const std::string& fen, bool isChess960, Thread* th);
// Text input/output
void from_fen(const std::string& fen, bool isChess960, Thread* th);
/// check for option's limits, but we could receive the new value directly from
/// the user by console window, so let's check the bounds anyway.
/// check for option's limits, but we could receive the new value directly from
/// the user by console window, so let's check the bounds anyway.
-void UCIOption::operator=(const string& v) {
+UCIOption& UCIOption::operator=(const string& v) {
assert(!type.empty());
if ( (type != "button" && v.empty())
|| (type == "check" && v != "true" && v != "false")
|| (type == "spin" && (atoi(v.c_str()) < min || atoi(v.c_str()) > max)))
assert(!type.empty());
if ( (type != "button" && v.empty())
|| (type == "check" && v != "true" && v != "false")
|| (type == "spin" && (atoi(v.c_str()) < min || atoi(v.c_str()) > max)))
if (type != "button")
currentValue = v;
if (on_change)
(*on_change)(*this);
if (type != "button")
currentValue = v;
if (on_change)
(*on_change)(*this);
UCIOption(const char* v, Fn* = NULL);
UCIOption(int v, int min, int max, Fn* = NULL);
UCIOption(const char* v, Fn* = NULL);
UCIOption(int v, int min, int max, Fn* = NULL);
- void operator=(const std::string& v);
+ UCIOption& operator=(const std::string& v);
operator int() const {
assert(type == "check" || type == "spin");
operator int() const {
assert(type == "check" || type == "spin");