Date: Sun, 21 May 2023 23:32:43 -0700
On Sunday, 21 May 2023 14:09:30 PDT Frederick Virchanza Gotham via Std-
Proposals wrote:
> I wrote the following code today; I have a struct for storing an IP
> address as well as two booleans (one for a FTP server and one for a
> Samba file server):
>
> struct IPFileShare {
> std::uint32_t ip;
<rant>IP addresses aren't 32-bit and haven't been since the late 1990s. Is
your code stuck in the 80s?</rant>
Let's not ever write or even suggest code that fails to work with IPv6.
> I think strictly speaking, the Standard says that this is undefined
> behaviour. How about we change the Standard to say that this
> const_cast is allowed so long as it has no effect on the sorting?
In addition to what Arthur said, std::set is not just about sorting, it's
about identity. The fact that your type seems to carry extra information that
is not part of the identity does not mean it's the case for all other types.
Let's not break the requirements without compelling reason. I didn't see a
compelling reason why it has to be this way. What other alternatives have you
explored and what were their drawbacks?
Proposals wrote:
> I wrote the following code today; I have a struct for storing an IP
> address as well as two booleans (one for a FTP server and one for a
> Samba file server):
>
> struct IPFileShare {
> std::uint32_t ip;
<rant>IP addresses aren't 32-bit and haven't been since the late 1990s. Is
your code stuck in the 80s?</rant>
Let's not ever write or even suggest code that fails to work with IPv6.
> I think strictly speaking, the Standard says that this is undefined
> behaviour. How about we change the Standard to say that this
> const_cast is allowed so long as it has no effect on the sorting?
In addition to what Arthur said, std::set is not just about sorting, it's
about identity. The fact that your type seems to carry extra information that
is not part of the identity does not mean it's the case for all other types.
Let's not break the requirements without compelling reason. I didn't see a
compelling reason why it has to be this way. What other alternatives have you
explored and what were their drawbacks?
-- Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org Software Architect - Intel DCAI Cloud Engineering
Received on 2023-05-22 06:32:46