Disservin / chess-library

C++ chess library
https://disservin.github.io/chess-library/
MIT License
63 stars 20 forks source link

Fix type error in iterators #83

Closed appleplectic closed 4 months ago

appleplectic commented 4 months ago

After building the library and adding the necessary #include statement, the project's build command fails due to a type mismatch:

  [1/2] Building CXX object CMakeFiles\cpp.dir\src\a.cpp.obj
  FAILED: CMakeFiles/a-cpp.dir/src/a.cpp.obj 
  C:\PROGRA~1\MICROS~3\2022\COMMUN~1\VC\Tools\MSVC\1439~1.335\bin\Hostx64\x64\cl.exe  /nologo /TP  -IC:\Users\a\source\repos\a-cpp\external /DWIN32 /D_WINDOWS /W3 /GR /EHsc /MDd /Ob0 /Od /RTC1 -std:c++20 -ZI /showIncludes /FoCMakeFiles\a-cpp.dir\src\a.cpp.obj /FdCMakeFiles\a-cpp.dir\ /FS -c C:\Users\a\source\repos\a-cpp\src\a.cpp
C:\Users\a\source\repos\a-cpp\external\chess.hpp(1268): error C2440: 'return': cannot convert from 'std::_Array_iterator<_Ty,256>' to 'chess::Movelist::iterator'
          with
          [
              _Ty=chess::Movelist::value_type
          ]
  C:\Users\a\source\repos\a-cpp\external\chess.hpp(1268): note: No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
C:\Users\a\source\repos\a-cpp\external\chess.hpp(1268): error C3615: constexpr function 'chess::Movelist::begin' cannot result in a constant expression
  C:\Users\a\source\repos\a-cpp\external\chess.hpp(1268): note: failure was caused by control reaching the end of a constexpr function
C:\Users\a\source\repos\a-cpp\external\chess.hpp(1269): error C2440: 'return': cannot convert from 'std::_Array_const_iterator<_Ty,256>' to 'chess::Movelist::const_iterator'
          with
          [
              _Ty=chess::Movelist::value_type
          ]
  C:\Users\a\source\repos\a-cpp\external\chess.hpp(1269): note: No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
C:\Users\a\source\repos\a-cpp\external\chess.hpp(1269): error C3615: constexpr function 'chess::Movelist::begin' cannot result in a constant expression
  C:\Users\a\source\repos\a-cpp\external\chess.hpp(1269): note: failure was caused by control reaching the end of a constexpr function
C:\Users\a\source\repos\a-cpp\external\chess.hpp(1272): error C2440: 'return': cannot convert from 'std::_Array_const_iterator<_Ty,256>' to 'chess::Movelist::const_iterator'
          with
          [
              _Ty=chess::Movelist::value_type
          ]
  C:\Users\a\source\repos\a-cpp\external\chess.hpp(1272): note: No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
C:\Users\a\source\repos\a-cpp\external\chess.hpp(1272): error C3615: constexpr function 'chess::Movelist::end' cannot result in a constant expression
  C:\Users\a\source\repos\a-cpp\external\chess.hpp(1272): note: failure was caused by control reaching the end of a constexpr function
C:\Users\a\source\repos\a-cpp\external\chess.hpp(1275): error C2440: 'return': cannot convert from 'std::reverse_iterator<std::_Array_iterator<_Ty,256>>' to 'std::reverse_iterator<chess::Movelist::iterator>'
          with
          [
              _Ty=chess::Movelist::value_type
          ]
  C:\Users\a\source\repos\a-cpp\external\chess.hpp(1275): note: No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
C:\Users\a\source\repos\a-cpp\external\chess.hpp(1279): error C2440: 'return': cannot convert from 'std::reverse_iterator<std::_Array_const_iterator<_Ty,256>>' to 'std::reverse_iterator<chess::Movelist::const_iterator>'
          with
          [
              _Ty=chess::Movelist::value_type
          ]
  C:\Users\a\source\repos\a-cpp\external\chess.hpp(1279): note: No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
C:\Users\a\source\repos\a-cpp\external\chess.hpp(1282): error C2440: 'return': cannot convert from 'std::reverse_iterator<std::_Array_iterator<_Ty,256>>' to 'std::reverse_iterator<chess::Movelist::iterator>'
          with
          [
              _Ty=chess::Movelist::value_type
          ]
  C:\Users\a\source\repos\a-cpp\external\chess.hpp(1282): note: No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
C:\Users\a\source\repos\a-cpp\external\chess.hpp(1284): error C2440: 'return': cannot convert from 'std::reverse_iterator<std::_Array_const_iterator<_Ty,256>>' to 'std::reverse_iterator<chess::Movelist::const_iterator>'
          with
          [
              _Ty=chess::Movelist::value_type
          ]
  C:\Users\a\source\repos\a-cpp\external\chess.hpp(1284): note: No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
  ninja: build stopped: subcommand failed.

Build All failed.
appleplectic commented 4 months ago

More information about my build system - Windows 11 Pro 22H2.

The Meson build system
Version: 1.0.1
Source dir: C:\Users\a\Downloads\chess-library
Build dir: C:\Users\a\Downloads\chess-library\build
Build type: native build
Project name: chess-library
Project version: undefined
C++ compiler for the host machine: c++ (gcc 13.1.0 "c++ (Rev6, Built by MSYS2 project) 13.1.0")
C++ linker for the host machine: c++ ld.bfd 2.40
Host machine cpu family: x86_64
Host machine cpu: x86_64
Program python found: YES (C:\Program Files\Python311\python.EXE)
Build targets in project: 3

Found ninja-1.11.1 at C:\Users\a\scoop\shims\ninja.EXE

Please let me know if you have any questions or suggestions!

Disservin commented 4 months ago

Hi thanks will take a look later, there are some library specific stuff missing like regenerating the single header file but I can do that later myself.