std::less<T *>
is guaranteed to provide total order, regardless of whether both pointers point into the same array.
In the latest draft of the standard, is the same true for the transparent function object std::less<void>
(std::less<>
) when you call its operator()
?
Obviously, the same question applies to std::greater
, but I assume they are specified the same.
The current draft from github does not contain any language to that effect; in fact, its definition of less<>
says explicitly "returns std::forward<T>(t) < std::forward<U>(u)
", which would be undefined behaviour for incomparable pointers. So... don't do it, I suppose.
If you need a heterogeneous pointer comparator, it's probably best to write your own template predicate which uses std::less<T*>()
at the appropriate moment.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With