Просмотр исходного кода

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 3 лет назад
Родитель
Сommit
6c46383e23
1 измененных файлов с 7 добавлено и 0 удалено
  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 {
     i8 rank; // zero indexed;
     i8 file;
+
     Square(StringView name);
+
+    Square(char const name[3])
+        : Square({ name, 2 })
+    {
+    }
+
     Square(int const& rank, int const& file)
         : rank(rank)
         , file(file)