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: Fri, 7 Oct 2022 20:40:21 +0800
But their name is "reference". Also, std::vector<bool>::reference has a
const assignment operator:

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


On Fri, Oct 7, 2022 at 8:34 PM Oleksandr Koval <
oleksandr.koval.dev_at_[hidden]> wrote:

> I think the intent here is to mimic value semantics since assignment
> actually changes referenced value. Making those functions `const` would be
> confusing.
>
> On Fri, Oct 7, 2022 at 2:42 PM 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?
>> --
>> Std-Proposals mailing list
>> Std-Proposals_at_[hidden]
>> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>>
>
>
> --
> Regards,
> Oleksandr Koval.
>

Received on 2022-10-07 12:40:50