Wednesday, October 30, 2013

How to write a compare function

std::map , std::set and std::sort may require that you write a custom compare function, so the elements can be sorted.
Writing the compare function correctly is critical, as a mistake can make your program crash.
There is a typical pattern you can follow, to write a compare function.