Check this & use functors!
http://stackoverflow.com/questions/1...01277#18301277
I am sure that 6 years ago, your advice would have been useful. Meanwhile, the OP's original project was canceled, the company went under, and he's had 4 different jobs since then.
Functors are nice, but when all you need is a simple static function that takes two pointers to double as arguments and returns a bool, adding all that overhead is overkill. And will the person who inherits this code take a look and ask, "Why the heck did they use functors when a static function would have worked just as well? Must be reading too many advanced C++ books".
Been there, done that. Functors have their uses and many C++ generic programming template constructs could not be implemented without them. Sorting a list of pointers by the value of the pointed-to instance isn't one of them.
Last edited by d_stranz; 18th August 2013 at 19:00.
Bookmarks