Created on 2025-12-16.00:00:00 last changed 1 week ago
Proposed resolution:
This wording is relative to N5032.
Modify [template.bitset.general] as indicated:
[…][…] // bit reference class reference { public: constexpr reference(const reference& x) noexcept; constexpr ~reference(); constexpr reference& operator=(bool x) noexcept; // for b[i] = x; constexpr reference& operator=(const reference& x) noexcept; // for b[i] = b[j]; constexpr const reference& operator=(bool x) const noexcept; constexpr operator bool() const noexcept; // for x = b[i]; constexpr bool operator~() const noexcept;// flips the bitconstexpr reference& flip() noexcept; // for b[i].flip(); friend constexpr void swap(reference x, reference y) noexcept; friend constexpr void swap(reference x, bool& y) noexcept; friend constexpr void swap(bool& x, reference y) noexcept; }; […]constexpr reference& reference::operator=(bool x) noexcept; constexpr reference& reference::operator=(const reference& x) noexcept; constexpr const reference& reference::operator=(bool x) const noexcept;-6- Effects: Sets the bit referred to by `*this` if `bool(x)` is `true`, and clears it otherwise.
-7- Returns: `*this`.constexpr reference::operator bool() const noexcept;-?- Returns: `true` if the value of the referred to bit is one, `false` otherwise.
constexpr bool reference::operator~() const noexcept;-?- Returns: `!bool(*this)`.
Modify [vector.bool.pspc] as indicated:
[…]constexpr reference& reference::operator=(bool x) noexcept; constexpr reference& reference::operator=(const reference& x) noexcept; constexpr const reference& reference::operator=(bool x) const noexcept;-7- Effects: Sets the bit referred to by `*this` when `bool(x)` is `true`, and clears it otherwise.
-8- Returns: `*this`.constexpr reference::operator bool() const noexcept;-?- Returns: `true` if the value of the referred to bit is one, `false` otherwise.
We haven't explicitly specified the return values of bitset<N>::reference::operator bool() and vector<bool, A>::reference::operator bool(), although the intended return values can be inferred from "a class that simulates a reference to a single bit in the sequence". Moreover, specification for bitset<N>::reference::operator~ seems completely missing, and the comment "flip the bit" seems misleading. Implementations consistently make the `operator~` return `!operator bool()`.
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2025-12-20 14:51:40 | admin | set | messages: + msg15834 |
| 2025-12-16 00:00:00 | admin | create | |