From d482e3a8905ee194bda3f67a21dda5132c21f30b Mon Sep 17 00:00:00 2001 From: Marco Costalba Date: Sun, 13 Aug 2017 11:01:26 -0700 Subject: [PATCH] Fix involuntary conversions of ExtMove to Move The trick is to create an ambiguity for the compiler in case an unwanted conversion to Move is attempted like in: ExtMove m1{Move(17),4}, m2{Move(4),17}; std::cout << (m1 < m2) << std::endl; // 1 std::cout << (m1 > m2) << std::endl; // 1(!) This fixes issue #1204 No functional change. --- src/movegen.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/movegen.h b/src/movegen.h index 8ae80118..82560570 100644 --- a/src/movegen.h +++ b/src/movegen.h @@ -42,6 +42,10 @@ struct ExtMove { operator Move() const { return move; } void operator=(Move m) { move = m; } + + // Inhibit unwanted implicit conversions to Move + // with an ambiguity that yields to a compile error. + operator float() const; }; inline bool operator<(const ExtMove& f, const ExtMove& s) { -- 2.39.2