cannot overload allocator because cannot define "less"
Dec 3, 2012 at 7:14pm UTC
Have next piece of code:
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 typedef struct _TMovedMols
unsigned int UniqueMolID:31;
unsigned int Direction:1;
_TMovedMols( int AUniqueMolID=0, int ADirection=0)
_TMovedMols( const _TMovedMols &other)
inline _TMovedMols & operator = ( const _TMovedMols &other)
return * this;
inline bool operator < ( const _TMovedMols &other) const
return UniqueMolID < other.UniqueMolID;
class TLocalSetAllocator ...;
typedef std::set<TMovedMols, less <TMovedMols>, TLocalSetAllocator<TMovedMols> > my_set_t;
test_set.cpp:146:3: error: ‘less’ was not declared in this scope
test_set.cpp:146:3: note: suggested alternative:
It's very first error form compiler, so no history. Does "less" supposed to be synonim to "<"?
Dec 3, 2012 at 7:17pm UTC
, and it is defined in the include file
(incidentally, why define your struct as both
? One name is enough)
To quote clang++,
test.cc:42:30: error: no template named 'less'; did you mean 'std::less'?
typedef std::set<TMovedMols, less <TMovedMols>,...
also, regarding your struct inside a union inside TMovedMols,
test.cc:10:13: error: anonymous structs are a GNU extension
Last edited on
Dec 3, 2012 at 7:26pm UTC
Dec 3, 2012 at 7:34pm UTC
You haven't namespace-qualified "less". It should be
According to the documentation on this very site:
is a template for a function object - that is, an object whose () operator has been overridden to return a value. The
template overrides the () operator to return the results of a < comparison between its two arguments.
In other words, if you create an object:
2 3 4
/* Set the values of a and b */
gives the same result as:
Topic archived. No new replies allowed.