I do not know in advance on which fields my dataset should be sorted, the sort fields are defined only by the user of the program. Is it possible to somehow define a comparison operator at run time ?
Well, you can define a functor which decides at run-time what to compare, maybe something like this:
bool operator()(const Structure& a, const Structure& b) const
return a.lastname < b.lastname;
return a.firstname < b.firstname;
Remember that max_value() and min_value() have to work correspondingly, though maybe a switch is not necessary.