-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Maybe remove the StrictTotallyOrdered constraint on std::less, default algorithm relations to a new std::totally_ordered_less #21
Comments
I'm against this. If the intent is to allow less to be used for Andrew Sutton On Wed, May 6, 2015 at 3:44 PM, Eric Niebler notifications@github.com wrote:
|
I feel likewise, but there is strong resistance on the committee for std::less requiring anything other than |
BTW, I like the |
Holding off on this one until I know which way the core language is going on the defaulted comparison operators proposal. |
I'd be a big fan of having a |
The requirement should be that operator<() is a natural total order. On Fri, Jul 31, 2015 at 1:34 PM, tvaneerd-rim notifications@github.com
|
Yes, I suspect we've had this conversation. I agree that makes sense for current STL, but we might have an opportunity here to get std::less back to having only one meaning instead of two. Sent from my BlackBerry 10 smartphone on the TELUS network. The requirement should be that operator<() is a natural total order. On Fri, Jul 31, 2015 at 1:34 PM, tvaneerd-rim notifications@github.com
— |
If we get some form of the lifting-operator accepted into language (like N3617 and P0119R0), then we could use That would allow us to have both raw wrapper ( |
If the core language gets defaulted or automatically generated comparison operators, then the issue is moot (I think). This issue is on the back burner until core picks a direction. |
Current default comparison operators paper N4475 supports |
Defaulted comparison operations in the core language is dead. @CaseyCarter believes the function objects ( |
My summary of the issue - |
I'd say default comparison operations are dead for now. I'm still pushing for == (ASAP), and opt-in operator< et al, with same generation as P0221 (ie <= is < || ==) |
<= should not be < || ==. That is an unnecessary comparison by default and it simply means people will be recommended to not write <= but instead write !>. |
If you want to support partial ordering, add an operator ⪯ () |
To be clear, I'm not suggesting that we drop the "strict weak order" requirement on |
Two thoughts, neither fully formed:
I know that goes again the general idea of semantic vs syntactic concepts/constraints. But I wonder if we are placing the constraints in the right place.
|
If I was to respecify
Note that template <class T>
bool foo(T x, T y) {
return less<T>{}(x, y); // Nope, underconstrained.
}
template <StrictTotallyOrdered T>
bool foo(T x, T y) {
return less<T>{}(x, y); // Ok: StrictTotallyOrdered subsumes __LessThanComparable
// and requires the result type to satisfy Boolean.
}
template <class T, StrictWeakOrder<T> C = less<T>>
bool foo(T x, T y) {
return less<T>{}(x, y); // Ok: we've explicitly required less<T> to induce a
// strict weak order on T.
return less<>{}(x, y); // Also ok: less<void>::operator()(T, T) is equivalent
// to less<T>::operator()(T, T).
} We've lost nothing relative to the current specification, and gained the ability to use |
I'm a proponent of strong semantics and enforcing those semantics to the On Thu, Nov 3, 2016 at 2:06 PM, Casey Carter notifications@github.com
|
C++14's I don't think we can continue the practice of using |
Why would less break things. I would nievly assume it simply deduces |
|
Casey and tomaszkam already answered this, but at least in the case that the two arguments have the same type — which is the common case, I would guess — dispatching to |
I would love to have a design for |
|
With the spaceship operator and opt-in generation of spaceship comparisons in C++20, is this issue effectively moot? |
Not quite because of legacy code, but it certainly gives us an easy answer to give people who don't want to spam out a bunch of operator overloads: change your |
Closing this since we settled on a constrained |
No description provided.
The text was updated successfully, but these errors were encountered: