An expression of type 'const CompareVPtrs' would lose some constants with uncertainty to cause

I implement the fifteenth puzzle in C ++, it raises the following error

Error 4 error C3848: expression having type 'const CompareVPtrs' would lose some const-volatile qualifiers in order to call 'bool CompareVPtrs::operator ()(Vertex *,Vertex *)' c:\program files\microsoft visual studio 11.0\vc\include\xfunctional 324 1 puzzle15 

This is my structure

 struct CompareVPtrs: public binary_function<Vertex*, Vertex*, bool> { bool operator()( Vertex *lhs, Vertex *rhs) { return equal((int *)lhs->state, (int *)lhs->state+16, (int *)rhs->state); } } CompareVP; 

The full source code of the game is https://gist.github.com/sunloverz/7338003

+6
source share
1 answer

This means that your comparison operator must be const :

 bool operator()( Vertex *lhs, Vertex *rhs) const { // ^^^^^ .... } 
+29
source

Source: https://habr.com/ru/post/957517/


All Articles