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

Compilation problem (STL set/map)
Posted by Igel_SK [VNTU] 19 Mar 2010 21:12
Submitting one problem I had a compilation error with making my own set comparator, although the program had succesfully been compiled by G++(GCC) 4.4.3 and Visual Studio 2008 compilers on my computer. By submitting some test programs I've found that the error is somehow related to the lower/upper_bound method of map and set containers. For instance, the code like this gets a compilation:

#include <set>
using namespace std;

struct Less
{
bool operator()(pair <int,int> a, pair <int,int> b)
  { return a.first < b.first; }
};

set <pair <int,int> , Less> s;
set <pair <int,int>, Less>::iterator it;

int main()
{
        s.insert(make_pair(1,1));
    it = s.lower_bound(make_pair(0,1));
    return 0;
}


The error message is following:

5bf1d001-ac4d-4354-a106-244d4befaf4e
S:\checker\compile\\Vc7\include\xtree(988): error: no instance of function "Less::operator()" matches the argument list and object (the object has cv-qualifiers that prevent a match)
            argument types are: (const std::pair<int, int>, const std::_Tree<std::_Tset_traits<std::pair<int, int>, Less, std::allocator<std::pair<int, int>>, false>>::key_type)
            object type is: const Less
              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<std::pair<int, int>, Less, std::allocator<std::pair<int, 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<std::pair<int, int>, Less, std::allocator<std::pair<int, int>>, false>]" at line 21 of "5bf1d001-ac4d-4354-a106-244d4befaf4e"

compilation aborted for 5bf1d001-ac4d-4354-a106-244d4befaf4e (code 2)


So I think that it makes some STL features unavailable and wish it to be fixed.