ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Common Board

Compile error - why ?
Posted by Mislav Balunović 5 Apr 2010 15:22
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)