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: Sun, 16 Oct 2022 08:47:27 +0800
You are missing:

constexpr reference& operator=( bool x ) noexcept;

and

constexpr reference& operator=( const reference& x ) noexcept;


On Sat, Oct 15, 2022 at 8:52 PM Arthur O'Dwyer <arthur.j.odwyer_at_[hidden]>
wrote:

> On Sat, Oct 15, 2022 at 6:29 AM blacktea hamburger via Std-Proposals <
> std-proposals_at_[hidden]> wrote:
>
>> 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.
>>
>
> And assignment operators. I don't know why you excluded them.
>>
>
> The assignment operators are already const in C++23.
> https://en.cppreference.com/w/cpp/container/vector_bool/reference
>
> –Arthur
>

Received on 2022-10-16 00:47:55