C++ Logo


Advanced search

Re: [std-proposals] Alteration of elements in a set (non-const iterator)

From: Oleksandr Koval <oleksandr.koval.dev_at_[hidden]>
Date: Mon, 22 May 2023 12:43:55 +0300
I don't think it's UB since the underlying memory is not read-only.
Arthur's solution can be improved using hints but I think that would still
require checking node(s) around the hint to verify that position is correct.
Btw, boost::container::set works in the way you need.

On Mon, May 22, 2023 at 9:32 AM Thiago Macieira via Std-Proposals <
std-proposals_at_[hidden]> wrote:

> 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?
> --
> Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
> Software Architect - Intel DCAI Cloud Engineering
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals

Oleksandr Koval.

Received on 2023-05-22 09:44:09