#pragma once #include #include template< typename T> class BoardT { public: BoardT(const BoardT & other) = delete; BoardT(const BoardT && other) = delete; BoardT & operator =(const BoardT & other) = delete; BoardT & operator =(const BoardT && other) = delete; static BoardT & GetInstance(){ if (instance == nullptr) { instance = new BoardT; } return * instance; } static bool SetSize(size_t row, size_t col) { if (not exists) { rows = row; cols = col; } return not exists; } static size_t Rows(void){ return rows; } static size_t Cols(void){ return cols; } void Move(size_t destRow, size_t destCol, size_t srcRow, size_t srcCol){ size_t dr{destRow%rows}, dc{destCol%cols}; size_t sr{srcRow%rows}, sc{srcCol%cols}; T empty; board[dr][dc] = std::move(board[sr][sc]); } T & operator [] (size_t row, size_t col){ size_t r{row%rows}, c{col%cols}; return board[r][c]; } private: BoardT(): board(rows,std::vector(cols)) {exists = true; }; ~BoardT() = default; static inline BoardT * instance{nullptr}; static inline size_t rows{10}; static inline size_t cols{10}; static inline bool exists{false}; std::vector> board; };