I would use
std::sort
for everything. As for automatically testing the classes, this most probably isn't possible (without some sort of a static analyzer; maybe clang-tidy has something?).