0

I have a "Tools" class which contains a lot of functions I commonly use. One is a parallel sort. I pass it a vector of Objects and a vector of indices, and it sorts the Objects and sorts the indices the same way (so the corresponding index is in the same position as its original corresponding object). The problem is, if I want to do this with a type that is unknown to Tools, it complains (makes sense... haha). Is there a way to define the < operator for Object somehow such that I can do this without having to modify Tools?

Thanks,

Dave

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by Ancient Dragon
0

>>Is there a way to define the < operator for Object somehow such that I can do this without having to modify Tools?

Of course there is. That's how std::sort function does it -- one of the arguments to std::sort is a user-defined function pointer, which sort() calls to determine sort order.

How to do it would depend on that Tools sort function and its arguments.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.