Subject: Re: std::less, tuple, pointer ordering
From: Ville Voutilainen (ville.voutilainen_at_[hidden])
Date: 2020-06-30 05:54:53
On Tue, 30 Jun 2020 at 13:37, Giuseppe D'Angelo via Std-Discussion
> > For users, I'm fine with their custom wrappers calling < on pointers, because it is implementation defined, and fine. The code you posted is probably defined on all platforms that Qt supports.
> I didn't want to get there right away... In principle I could also be
> happy if an implementation provided a strong guarantee that operator< on
> pointers gives a total order (e.g. some constant/macro in a standard
> header so I could static_assert on it). But that is a complete
> non-starter: both GCC and MSVC already optimize away code based on
> unspecified pointer comparisons:
Indeed. That ship sailed while we were happily sleeping thinking "no
compiler will ever do that".
We ended up using the pre-c++20 builtin almost-equivalent of
is_constant_evaluated to fix std::less.
If you're still thinking that comparing pointers is "fine for all
relevant platforms", wake up. The compilers
walked through the wide-open unspecified-door years ago.
STD-DISCUSSION list run by herb.sutter at gmail.com
Older Archives on Google Groups