hi, what is needed for the lexicographic class to be included into boost?
I don't know, but I think there are several ideas which haven't been addressed and that we should at least have a look at:
a) Short-circuiting b) Unnamed functions
bool operator < (person const &p1, person const &p2) { return boost::lexicographic (p1.lastname, p2.lastname, cmp_lower) (p1.firstname, p2.firstname, cmp_lower) (p2.age, p1.age); }
The two points listed above are both visible here: Even if there are no persons with the same name, age is accessed. Even worse, it may be a costly method age() and the unaware user creates much worse code than using nested if-else-structures.
Also, you might not want to define operator<. Sometimes, you just need it in one place, e.g. std::sort( v.begin(), v.end(), /*HERE*/ );
I don't know how to solve these problems, though. The only idea I have removes the comparator and uses macros. It does provide short-circuiting, but I fear I might get stoned now. Anyway:
#define false(a,b) (!((a)==(b)))?((a)<(b)):!true #define true(a,b) ((a)==(b))?((a)<(b)):false #define BOOST_LEXICOGRAPHIC false
bool operator<( const person& p1, const person& p2 ) { return BOOST_LEXICOGRAPHIC ( p1.lastname, p2.lastname ) ( p1.firstname, p2.firstname ) ( p1.age, p2.age ); }
Regards, Daniel
-- Daniel Frey
aixigo AG - financial training, research and technology Schloß-Rahe-Straße 15, 52072 Aachen, Germany fon: +49 (0)241 936737-42, fax: +49 (0)241 936737-99 eMail: [EMAIL PROTECTED], web: http://www.aixigo.de
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost