Why?
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposal...@isocpp.org.
To post to this group, send email to std-pr...@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/132ff725-5463-4d9c-a291-3314a56dca50%40isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/19271ac8-cb01-4290-8126-ca57a87ef4d9%40isocpp.org.
Why not?
Why not?I can think of a few reasons.Firstly, because it doesn't make much sense from a semantics perspective. The first and second properties of a pair (just like the elements of a tuple) are not really intended to be compared with one another - they are wholly separate entities related only by some previous action (e.g. a map from one to the other, or as multiple return values of a function), and the two having the comparable type is rare.
If they ARE meant to be compared and are the same type, you should probably be using a std::array. If they are two different types with some defined comparison operation, you're looking at an edge case for which custom code is probably suitable (especially as you'd probably want to document it properly).
Secondly, getting the min and max of a pair is trivial. You can write min(p.first, p.second) with minimal effort, and is very readable. In fact, I would consider it considerably more readable than min(p).
I am not discussing "how it works". I want to collect opinions about introducing these functions.
Even if two objects have the same type they can be semantically different.
Sometimes the more detailed code means its less readability.
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
Perhaps a more general approach, which would also solve your use case trivially, is a proposal to allow std::pair<T,T> to be convertible to a range of T?