You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I found an instance where ranges::sort(vec) fails to compile but std::sort(vec.begin(), vec.end()) compiles. The type of vec is std::vector<rule_t>, and the definition of rule_t is:
This is because the concept requirements on ordered_less (and ranges::less as well) are stricter than the (non-existent) ones in the standard library.
Should ranges::sort default to requiring TotallyOrdered? ranges::less may be less (ha ha) surprising to users. (In my case I can and will just define operator== etc, but I can imagine there may be cases where that is not desirable.)
Is it necessary for less to require the presence of operators >, <=, and >=? I understand that all of these operators should be defined if any are, but it still feels surprising that less is not callable on a type that defines operator<. (At least when we do get concepts the error messages will finally be understandable).
The text was updated successfully, but these errors were encountered:
Should ranges::sort default to requiring TotallyOrdered? ranges::less
may be less (ha ha) surprising to users. (In my case I can and will just
define operator== etc, but I can imagine there may be cases where that is
not desirable.)
What cases? Are they imaginary or do you have examples that serve a
practical purpose?
Please do not try to drive algorithm requirements based on imaginary use
cases.
Is it necessary for less to require the presence of operators >, <=,
and >=? I understand that all of these operators should be defined if any
are, but it still feels surprising that less is not callable on a type
that defines operator<. (At least when we do get concepts the error
messages will finally be understandable)
These are both reasonable requirements. Those algorithms are derived from
the concept of a total order (or in some case a weak order) and their
associated operations.
For example, if you can call less(), surely you can call greater() -- after
all, if something is not less, then it may be greater, right? And of course
greater() is defined using >.
Oops, now rule_t works with less() but not greater(). This also means that
you can't sort() in descending order.
I know that greater() is not defined in this library, but it is defined by
the standard, and it's defined to use >.
I found an instance where
ranges::sort(vec)
fails to compile butstd::sort(vec.begin(), vec.end())
compiles. The type ofvec
isstd::vector<rule_t>
, and the definition ofrule_t
is:This is because the concept requirements on
ordered_less
(andranges::less
as well) are stricter than the (non-existent) ones in the standard library.Should
ranges::sort
default to requiring TotallyOrdered?ranges::less
may be less (ha ha) surprising to users. (In my case I can and will just defineoperator==
etc, but I can imagine there may be cases where that is not desirable.)Is it necessary for
less
to require the presence of operators>
,<=
, and>=
? I understand that all of these operators should be defined if any are, but it still feels surprising thatless
is not callable on a type that definesoperator<
. (At least when we do get concepts the error messages will finally be understandable).The text was updated successfully, but these errors were encountered: