исправь ошибку: SquareSet SquareSet::operator&=(const IntoSquareSet &other) { this->mask…
- User
исправь ошибку: SquareSet SquareSet::operator&=(const IntoSquareSet &other) { this->_mask &= SquareSet(other)._mask; this->_iter = scan_forward(this->mask); return *this; } typedef std::variant<Bitboard, SquareSet, std::vector> IntoSquareSet; erorr:1> C:\Users\void\Desktop\с++ project\Project1\chess\chess.cpp(5415,16): 1> во время компиляции функции-члена класс шаблон "std::variant<chess::Bitboard,chess::SquareSet,std::vector<int,std::allocator>>::variantchess::SquareSet&,0(_Ty) noexcept()" 1> with 1> [ 1> _Ty=chess::SquareSet & 1> ] 1> E:\VS_CUM\VC\Tools\MSVC\14.38.33130\include\variant(985,44): 1> выполняется компиляция ссылки на шаблон переменной "const bool is_nothrow_constructible_v<chess::SquareSet,chess::SquareSet &>" 1> E:\VS_CUM\VC\Tools\MSVC\14.38.33130\include\type_traits(941,57): 1> во время компиляции функции-члена класс шаблон "std::variant<chess::Bitboard,chess::SquareSet,std::vector<int,std::allocator>>::variantchess::SquareSet&,0(_Ty) noexcept()" 1> with 1> [ 1> _Ty=chess::SquareSet & 1> ]
- Assistant
SquareSet SquareSet::operator&=(const IntoSquareSet &other) { this->_mask &= std::get(other)._mask; this->_iter = scan_forward(this->_mask); return *this; }
- User
typedef std::variant<Bitboard, SquareSet, std::vector> IntoSquareSet; erorr:1> C:\Users\void_\Desktop\с++ project\Project1\chess\chess.cpp(5415,16): 1> во время компиляции функции-члена класс шаблон "std::variant<chess::Bitboard,chess::SquareSet,std::vector<int,std::allocator>>::variantchess::SquareSet&,0(_Ty) noexcept()" 1> with 1> [ 1> _Ty=chess::SquareSet & 1> ] 1> E:\VS_CUM\VC\Tools\MSVC\14.38.33130\include\variant(985,44): 1> выполняется компиляция ссылки на шаблон переменной "const bool is_nothrow_constructible_v<chess::SquareSet,chess::SquareSet &>" 1> E:\VS_CUM\VC\Tools\MSVC\14.38.33130\include\type_traits(941,57): 1> во время компиляции функции-члена класс шаблон "std::variant<chess::Bitboard,chess::SquareSet,std::vector<int,std::allocator>>::variantchess::SquareSet&,0(_Ty) noexcept()" 1> with 1> [ 1> _Ty=chess::SquareSet & 1> ]
- Assistant
The error message suggests that there is an issue with the construction of the
std::variantobject. It seems that the issue is related to constructing astd::variantobject with a reference to achess::SquareSettype.To fix this error, you can modify the
IntoSquareSettypedef to use a reference_wrapper for theSquareSettype:typedef std::variant<Bitboard, std::reference_wrapper<SquareSet>, std::vector<Square>> IntoSquareSet;Then, when accessing the
SquareSetobject from thestd::variant, you need to usestd::get<std::reference_wrapper<SquareSet>>(other).get():this->_mask &= std::get<std::reference_wrapper<SquareSet>>(other).get()._mask;This should resolve the compiler error related to constructing the
std::variantobject with a reference.