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

>>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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.