I disagree with your disagreement ;-) Reading insert_ordered(...) is easier (for me) than guessing what the for-loop is intended to do exactly. But in the end you decide what ends up in the simutrans code :-)
I just want to point out that the same method is already used in several other places:
% git grep 'operator ()'
gui/citylist_stats_t.cc: bool operator ()(const stadt_t* a, const stadt_t* b)
gui/curiositylist_stats_t.cc: bool operator ()(const gebaeude_t* a, const gebaeude_t* b)
gui/factorylist_stats_t.cc: bool operator ()(const fabrik_t* a, const fabrik_t* b)
gui/labellist_stats_t.cc: bool operator ()(const koord a, const koord b)
and used for std::sort.
As we are already talking about readability: I noticed simutrans has constructs like this
// only this works with O3 optimisation!
return ((a.x-b.x)|(a.y-b.y))==0;
instead of the (more readable)
return (a.x == b.x) && (a.y == b.y);
which also should work with any optimization setting. Is there any reason to prefer the first version? I doubt it makes much of a difference performance-wise (actually I would ****ume integer arithmetic to be slower than equality tests). But the main point is that I think readability is more important than a few CPU cycles in most cases.
Also, is there any special reason behind using vector_tpl instead of std::vector? std::vector should be supported everywhere by now.
Ansgar