- // Overload operator<<() to make it easier to print moves in a coordinate
- // notation compatible with UCI protocol.
- std::ostream& operator<<(std::ostream& os, Move m) {
-
- bool chess960 = (os.iword(0) != 0); // See set960()
- return os << move_to_uci(m, chess960);
- }
-
- // When formatting a move for std::cout we must know if we are in Chess960 or
- // not. To keep using the handy operator<<() on the move the trick is to embed
- // this flag in the stream itself. Function-like named enum set960 is used as
- // a custom manipulator and the stream internal general-purpose array, accessed
- // through ios_base::iword(), is used to pass the flag to the move's operator<<
- // that will read it to properly format castling moves.
- enum set960 {};
-
- std::ostream& operator<<(std::ostream& os, const set960& f) {
-
- os.iword(0) = f;
- return os;
- }
-