Compile error - why ?
In my code I have this:
struct cmpf {
bool operator ( )( const int &i, const int &j ){
if ( dist[i] != dist[j] ) return dist[i] < dist[j];
return i < j;
}
};
...
S.erase(i);
Why am I receiving this boring compile error down here, it doesn't make sense!
e6a69c8b-fd41-4c39-9a60-1c924ab01be4
S:\checker\compile\\Vc7\include\xtree(988): error: no instance of function "cmpf::operator()" matches the argument list and object (the object has cv-qualifiers that prevent a match)
argument types are: (const int, const std::_Tree<std::_Tset_traits<int, cmpf, std::allocator<int>, false>>::key_type)
object type is: const cmpf
if (this->comp(_Key(_Pnode), _Keyval))
^
detected during:
instantiation of "std::_Tree<_Traits>::_Nodeptr std::_Tree<_Traits>::_Lbound(const std::_Tree<_Traits>::key_type &) const [with _Traits=std::_Tset_traits<int, cmpf, std::allocator<int>, false>]" at line 801
instantiation of "std::_Tree<_Traits>::iterator std::_Tree<_Traits>::lower_bound(const std::_Tree<_Traits>::key_type &) [with _Traits=std::_Tset_traits<int, cmpf, std::allocator<int>, false>]" at line 821
instantiation of "std::_Tree<_Traits>::_Pairii std::_Tree<_Traits>::equal_range(const std::_Tree<_Traits>::key_type &) [with _Traits=std::_Tset_traits<int, cmpf, std::allocator<int>, false>]" at line 757
instantiation of "std::_Tree<_Traits>::size_type std::_Tree<_Traits>::erase(const std::_Tree<_Traits>::key_type &) [with _Traits=std::_Tset_traits<int, cmpf, std::allocator<int>, false>]" at line 71 of "e6a69c8b-fd41-4c39-9a60-1c924ab01be4"
S:\checker\compile\\Vc7\include\xtree(1089): error: no instance of function "cmpf::operator()" matches the argument list and object (the object has cv-qualifiers that prevent a match)
argument types are: (const std::_Tree<std::_Tset_traits<int, cmpf, std::allocator<int>, false>>::key_type, const int)
object type is: const cmpf
if (this->comp(_Keyval, _Key(_Pnode)))
^
detected during:
instantiation of "std::_Tree<_Traits>::_Nodeptr std::_Tree<_Traits>::_Ubound(const std::_Tree<_Traits>::key_type &) const [with _Traits=std::_Tset_traits<int, cmpf, std::allocator<int>, false>]" at line 811
instantiation of "std::_Tree<_Traits>::iterator std::_Tree<_Traits>::upper_bound(const std::_Tree<_Traits>::key_type &) [with _Traits=std::_Tset_traits<int, cmpf, std::allocator<int>, false>]" at line 821
instantiation of "std::_Tree<_Traits>::_Pairii std::_Tree<_Traits>::equal_range(const std::_Tree<_Traits>::key_type &) [with _Traits=std::_Tset_traits<int, cmpf, std::allocator<int>, false>]" at line 757
instantiation of "std::_Tree<_Traits>::size_type std::_Tree<_Traits>::erase(const std::_Tree<_Traits>::key_type &) [with _Traits=std::_Tset_traits<int, cmpf, std::allocator<int>, false>]" at line 71 of "e6a69c8b-fd41-4c39-9a60-1c924ab01be4"
compilation aborted for e6a69c8b-fd41-4c39-9a60-1c924ab01be4 (code 2)