Sahnvour / PathFinder

A small, simple and generic C++ path finding library.
BSD 2-Clause "Simplified" License
83 stars 26 forks source link

Cannot compile image.cpp #3

Closed nm17 closed 6 years ago

nm17 commented 6 years ago
Using built-in specs.
COLLECT_GCC=g++-7
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 7.2.0-1ubuntu1' --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-7 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 7.2.0 (Ubuntu 7.2.0-1ubuntu1) 

In file included from image.cpp:24:0:
../src/PathFinder.h: In member function ‘bool PathFinder<TNode>::findPath(std::vector<TNode*>&, int)’:
../src/PathFinder.h:73:38: error: type/value mismatch at argument 1 in template parameter list for ‘template<class _Tp, class _Alloc> class std::vector’
    std::vector<TAlgorithm::node_type*> path;
                                      ^
../src/PathFinder.h:73:38: note:   expected a type, got ‘(TAlgorithm:: node_type * <expression error>)’
../src/PathFinder.h:73:38: error: template argument 2 is invalid
../src/PathFinder.h:77:10: error: request for member ‘reserve’ in ‘path’, which is of non-class type ‘int’
     path.reserve(hint);
          ^~~~~~~
../src/PathFinder.h:87:35: error: no matching function for call to ‘rbegin(int&)’
    for(auto rit = std::rbegin(path); rit != std::rend(path); ++rit)
                                   ^
In file included from /usr/include/c++/7/vector:66:0,
                 from ../src/PathFinder.h:3,
                 from image.cpp:24:
/usr/include/c++/7/bits/range_access.h:138:5: note: candidate: template<class _Container> constexpr decltype (__cont.rbegin()) std::rbegin(_Container&)
     rbegin(_Container& __cont) -> decltype(__cont.rbegin())
     ^~~~~~
/usr/include/c++/7/bits/range_access.h:138:5: note:   template argument deduction/substitution failed:
/usr/include/c++/7/bits/range_access.h: In substitution of ‘template<class _Container> constexpr decltype (__cont.rbegin()) std::rbegin(_Container&) [with _Container = int]’:
../src/PathFinder.h:87:35:   required from here
/usr/include/c++/7/bits/range_access.h:138:51: error: request for member ‘rbegin’ in ‘__cont’, which is of non-class type ‘int’
     rbegin(_Container& __cont) -> decltype(__cont.rbegin())
                                            ~~~~~~~^~~~~~
/usr/include/c++/7/bits/range_access.h:148:5: note: candidate: template<class _Container> constexpr decltype (__cont.rbegin()) std::rbegin(const _Container&)
     rbegin(const _Container& __cont) -> decltype(__cont.rbegin())
     ^~~~~~
/usr/include/c++/7/bits/range_access.h:148:5: note:   template argument deduction/substitution failed:
/usr/include/c++/7/bits/range_access.h: In substitution of ‘template<class _Container> constexpr decltype (__cont.rbegin()) std::rbegin(const _Container&) [with _Container = int]’:
../src/PathFinder.h:87:35:   required from here
/usr/include/c++/7/bits/range_access.h:148:57: error: request for member ‘rbegin’ in ‘__cont’, which is of non-class type ‘const int’
     rbegin(const _Container& __cont) -> decltype(__cont.rbegin())
                                                  ~~~~~~~^~~~~~
/usr/include/c++/7/bits/range_access.h:178:5: note: candidate: template<class _Tp, long unsigned int _Nm> constexpr std::reverse_iterator<_Tp*> std::rbegin(_Tp (&)[_Nm])
     rbegin(_Tp (&__arr)[_Nm])
     ^~~~~~
/usr/include/c++/7/bits/range_access.h:178:5: note:   template argument deduction/substitution failed:
In file included from image.cpp:24:0:
../src/PathFinder.h:87:35: note:   mismatched types ‘_Tp [_Nm]’ and ‘int’
    for(auto rit = std::rbegin(path); rit != std::rend(path); ++rit)
                                   ^
In file included from /usr/include/c++/7/vector:66:0,
                 from ../src/PathFinder.h:3,
                 from image.cpp:24:
/usr/include/c++/7/bits/range_access.h:198:5: note: candidate: template<class _Tp> constexpr std::reverse_iterator<const _Tp*> std::rbegin(std::initializer_list<_Tp>)
     rbegin(initializer_list<_Tp> __il)
     ^~~~~~
/usr/include/c++/7/bits/range_access.h:198:5: note:   template argument deduction/substitution failed:
In file included from image.cpp:24:0:
../src/PathFinder.h:87:35: note:   mismatched types ‘std::initializer_list<_Tp>’ and ‘int’
    for(auto rit = std::rbegin(path); rit != std::rend(path); ++rit)
                                   ^
../src/PathFinder.h:87:59: error: no matching function for call to ‘rend(int&)’
    for(auto rit = std::rbegin(path); rit != std::rend(path); ++rit)
                                                           ^
In file included from /usr/include/c++/7/vector:66:0,
                 from ../src/PathFinder.h:3,
                 from image.cpp:24:
/usr/include/c++/7/bits/range_access.h:158:5: note: candidate: template<class _Container> constexpr decltype (__cont.rend()) std::rend(_Container&)
     rend(_Container& __cont) -> decltype(__cont.rend())
     ^~~~
/usr/include/c++/7/bits/range_access.h:158:5: note:   template argument deduction/substitution failed:
/usr/include/c++/7/bits/range_access.h: In substitution of ‘template<class _Container> constexpr decltype (__cont.rend()) std::rend(_Container&) [with _Container = int]’:
../src/PathFinder.h:87:59:   required from here
/usr/include/c++/7/bits/range_access.h:158:49: error: request for member ‘rend’ in ‘__cont’, which is of non-class type ‘int’
     rend(_Container& __cont) -> decltype(__cont.rend())
                                          ~~~~~~~^~~~
/usr/include/c++/7/bits/range_access.h:168:5: note: candidate: template<class _Container> constexpr decltype (__cont.rend()) std::rend(const _Container&)
     rend(const _Container& __cont) -> decltype(__cont.rend())
     ^~~~
/usr/include/c++/7/bits/range_access.h:168:5: note:   template argument deduction/substitution failed:
/usr/include/c++/7/bits/range_access.h: In substitution of ‘template<class _Container> constexpr decltype (__cont.rend()) std::rend(const _Container&) [with _Container = int]’:
../src/PathFinder.h:87:59:   required from here
/usr/include/c++/7/bits/range_access.h:168:55: error: request for member ‘rend’ in ‘__cont’, which is of non-class type ‘const int’
     rend(const _Container& __cont) -> decltype(__cont.rend())
                                                ~~~~~~~^~~~
/usr/include/c++/7/bits/range_access.h:188:5: note: candidate: template<class _Tp, long unsigned int _Nm> constexpr std::reverse_iterator<_Tp*> std::rend(_Tp (&)[_Nm])
     rend(_Tp (&__arr)[_Nm])
     ^~~~
/usr/include/c++/7/bits/range_access.h:188:5: note:   template argument deduction/substitution failed:
In file included from image.cpp:24:0:
../src/PathFinder.h:87:59: note:   mismatched types ‘_Tp [_Nm]’ and ‘int’
    for(auto rit = std::rbegin(path); rit != std::rend(path); ++rit)
                                                           ^
In file included from /usr/include/c++/7/vector:66:0,
                 from ../src/PathFinder.h:3,
                 from image.cpp:24:
/usr/include/c++/7/bits/range_access.h:208:5: note: candidate: template<class _Tp> constexpr std::reverse_iterator<const _Tp*> std::rend(std::initializer_list<_Tp>)
     rend(initializer_list<_Tp> __il)
     ^~~~
/usr/include/c++/7/bits/range_access.h:208:5: note:   template argument deduction/substitution failed:
In file included from image.cpp:24:0:
../src/PathFinder.h:87:59: note:   mismatched types ‘std::initializer_list<_Tp>’ and ‘int’
    for(auto rit = std::rbegin(path); rit != std::rend(path); ++rit)
                                                           ^
image.cpp: In member function ‘virtual float Square::distanceTo(AStarNode*) const’:
image.cpp:69:11: error: ‘sqrtf’ was not declared in this scope
    return sqrtf( static_cast<float>(newX*newX + newY*newY) );
           ^~~~~
image.cpp:69:11: note: suggested alternative: ‘strtof’
    return sqrtf( static_cast<float>(newX*newX + newY*newY) );
           ^~~~~
           strtof
In file included from image.cpp:24:0:
../src/PathFinder.h: In instantiation of ‘bool PathFinder<TNode>::findPath(std::vector<TNode*>&, int) [with TAlgorithm = AStar; TNode = Square]’:
image.cpp:158:33:   required from here
../src/PathFinder.h:79:9: error: no matching function for call to ‘AStar::getPath(Square*&, Square*&, int&)’
    bool pathFound = algorithm.getPath(m_start, m_goal, path);
         ^~~~~~~~~
In file included from image.cpp:25:0:
../src/AStar.h:119:8: note: candidate: virtual bool AStar::getPath(AStarNode*, AStarNode*, std::vector<AStarNode*, std::allocator<AStarNode*> >&)
   bool getPath(AStarNode* start, AStarNode* goal, std::vector<AStarNode*>& path);
        ^~~~~~~
../src/AStar.h:119:8: note:   no known conversion for argument 3 from ‘int’ to ‘std::vector<AStarNode*, std::allocator<AStarNode*> >&’
Sahnvour commented 6 years ago

You should probably change the line PathFinder.h:73 to be std::vector<typename TAlgorithm::node_type*> path; (added typename), and add #include <iterator> to the same file. Send me a PR and I'll accept it if it works.

nm17 commented 6 years ago

Ok