C++ Logo

std-proposals

Advanced search

Re: [std-proposals] The member functions of std::vector<bool>::reference and std::bitset::reference (except for ctors and dtors) should all be const

From: blacktea hamburger <greenteahamburger_at_[hidden]>
Date: Sat, 15 Oct 2022 18:29:51 +0800
And assignment operators. I don't know why you excluded them.

On Friday, October 7, 2022, Arthur O'Dwyer <arthur.j.odwyer_at_[hidden]>
wrote:
> On Fri, Oct 7, 2022 at 7:42 AM blacktea hamburger via Std-Proposals <
std-proposals_at_[hidden]> wrote:
>>
>> std::vector<bool>::reference and std::bitset::reference are both
proxies, so even if they themselves are const, they can still be used to
change the bit they reference.
>> Are there any issues?
>
> IIUC, you're talking about Jonathan Wakely's P/R of LWG 3638, and
proposing that it should be amended to say
> constexpr void flip() const noexcept;
> I would tend to agree with this suggestion (although `flip()` is a dumb
member function to have, in general).
> And then bitset::reference [template.bitset.general] should be updated in
the same way:
> constexpr reference& flip() noexcept;
> constexpr const reference& flip() const noexcept;
> If you're proposing anything else in addition to those two changes to
`flip()`, it's not obvious to me from what you said.
> –Arthur

Received on 2022-10-15 10:29:53