I am trying to create a Set using the LEDA library... I am adding elements of a Class which has a compare()
method defined under namespace LEDA... Unfortunately, the compiler is unable to locate the compare function for this class... Here's the error message...
/home/user/Desktop/leda/incl/LEDA/core/set.h:
In constructor ‘leda::set<E, set_impl>::set() [with E = Operator*, set_impl = leda::avl_tree]’:
../src/suite.cc:52: instantiated from here /home/user/Desktop/leda/incl/LEDA/core/set.h:71: error: no matches converting function ‘compare’ to type ‘int (*)(class Operator* const&, class Operator* const&)’
/home/user/Desktop/leda/incl/LEDA/internal/param_types.h:351: error: candidates are: int leda::compare(const char&, const char&)
/home/user/Desktop/leda/incl/LEDA/internal/param_types.h:352: error: int leda::compare(const unsigned char&, const unsigned char&)
/home/user/Desktop/leda/incl/LEDA/internal/param_types.h:353: error: int leda::compare(const int&, const int&)
/home/user/Desktop/leda/incl/LEDA/internal/param_types.h:354: error: int leda::compare(const unsigned int&, const unsigned int&)
/home/user/Desktop/leda/incl/LEDA/internal/param_types.h:355: error: int leda::compare(const long int&, const long int&)
/home/user/Desktop/leda/incl/LEDA/internal/param_types.h:356: error: int leda::compare(const long unsigned int&, const long unsigned int&)
/home/user/Desktop/leda/incl/LEDA/internal/param_types.h:357: error: int leda::compare(const float&, const float&)
/home/user/Desktop/leda/incl/LEDA/internal/param_types.h:358: error: int leda::compare(const double&, const double&)
/home/user/Desktop/leda/incl/LEDA/core/string.h:382: error: int leda::compare(const leda::string&, const leda::string&)
LEDA requires the compare()
method be defined for elements of a set
.
Suite::Suite (set<Operator*> *ops)
: operators(ops!=NULL ? ops : new set<Operator*>)
{
I have this compare method defined according to LEDA requirements...
namespace leda {
inline int compare (Operator* const &a, Operator* const &b)
{
return a==b ? 0 : a<b ? -1 : 1;
}
};
But it still cannot find it in LEDA librabry's set.h here..
set() { cmp_ptr = compare; }
It tries to find the pointer to the compare()
method and assigns it to cmp_ptr
... but cannot find it...
I've defined the method but somehow it doesn't get recognized?
Update: I seem to be having this problem with all compare()
definitions.... including other classes in Sets..