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

Discussion of Problem 1067. Disk Tree

Why CE. I used set.
Posted by Ilya Mitin 10 May 2008 18:39
I get CE. Why?

#include <iostream>
#include <vector>
#include <sstream>
#include <set>
using namespace std;

template < class TypeTree > class less_of_tree
{
public :
________bool operator () (TypeTree a, TypeTree b)
________{
________________return a.name < b.name;
________}
};

class tree
{
public :
________string name;
________set < tree, less_of_tree < tree > > child;

________tree ();
________tree (string s);
________void add (int x, vector < string > way);
________void print (string row);
};
...

e:\judge\Judge\Vc7\include\xtree(988): error: no instance of function "less_of_tree<TypeTree>::operator() [with TypeTree=tree]" matches the argument list and object (the object has cv-qualifiers that prevent a match)
            argument types are: (const tree, const std::_Tree<std::_Tset_traits<tree, less_of_tree<tree>, std::allocator<tree>, false>>::key_type)
            object type is: const less_of_tree<tree>
     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<tree, less_of_tree<tree>, std::allocator<tree>, 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<tree, less_of_tree<tree>, std::allocator<tree>, false>]" at line 779
            instantiation of "std::_Tree<_Traits>::iterator std::_Tree<_Traits>::find(const std::_Tree<_Traits>::key_type &) [with _Traits=std::_Tset_traits<tree, less_of_tree<tree>, std::allocator<tree>, false>]" at line 50 of "43d08e8e-4606-476a-85b3-38e5b7230ae9"

Edited by author 10.05.2008 18:42
Re: Why CE. I used set.
Posted by diver_ru (Fishburg SAAT) 10 May 2008 18:59
try to use 'const':

template < class TypeTree > class less_of_tree
{
public :
________bool operator () (const TypeTree a, const TypeTree b) const // <-- here
________{
________________return a.name < b.name;
________}
};

Edited by author 10.05.2008 19:00