News for hackers. Stuff that matters.
Re:Code Smells: Iteration by throwaway613834 on Wednesday August 23, 2017 @03:04PM (#15084192)
One problem in C++ is if you define a struct then you have to define a bunch of operators yourself (operator<, etc.) which gets annoying after you've realized you've needed them a bunch of times.
Re:Code Smells: Iteration by marcosdumay on Wednesday August 23, 2017 @04:13PM (#15084638)
Does C++ Pair<> define operator< and operator>?

That's surprising, and for me looks completely uncalled for.

EDIT: Just looked into Haskell (because it's easier), and tuples do derive Ord there. Is there some universal convention I'm missing?

Re:Code Smells: Iteration by throwaway613834 on Wednesday August 23, 2017 @05:34PM (#15085394)
> Is there some universal convention I'm missing?

Tuples are always compared lexicographically, is the universal convention. Not sure if that's what you might be missing?

Re:Code Smells: Iteration by khedoros1 on Wednesday August 23, 2017 @05:37PM (#15085421)
> Does C++ Pair<> define operator< and operator>?

It does.

std::sort(pairarray.begin(),pairarray.end()) works about how you'd expect, as long as operator< is defined for the constituent types of the pair.