C++ Logo


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: Arthur O'Dwyer <arthur.j.odwyer_at_[hidden]>
Date: Fri, 7 Oct 2022 11:50:38 -0400
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
<https://cplusplus.github.io/LWG/issue3638>, 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
<https://eel.is/c++draft/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.


Received on 2022-10-07 15:50:50