Explorar o código

LibChess: Add convenience constructor for Chess::Square

It didn't feel right to add sv suffixes to 2-character strings, so I
added this convenience constructor.
sin-ack %!s(int64=3) %!d(string=hai) anos
pai
achega
6c46383e23
Modificáronse 1 ficheiros con 7 adicións e 0 borrados
  1. 7 0
      Userland/Libraries/LibChess/Chess.h

+ 7 - 0
Userland/Libraries/LibChess/Chess.h

@@ -57,7 +57,14 @@ constexpr Piece EmptyPiece = { Color::None, Type::None };
 struct Square {
 struct Square {
     i8 rank; // zero indexed;
     i8 rank; // zero indexed;
     i8 file;
     i8 file;
+
     Square(StringView name);
     Square(StringView name);
+
+    Square(char const name[3])
+        : Square({ name, 2 })
+    {
+    }
+
     Square(int const& rank, int const& file)
     Square(int const& rank, int const& file)
         : rank(rank)
         : rank(rank)
         , file(file)
         , file(file)