diff --git a/source/containers.tex b/source/containers.tex index dc9719bf3b..2c6d4ccc69 100644 --- a/source/containers.tex +++ b/source/containers.tex @@ -10480,13 +10480,17 @@ // bit reference class @\libmember{reference}{vector}@ { public: - constexpr reference(const reference&) = default; + constexpr reference(const reference& x) noexcept; constexpr ~reference(); - constexpr operator bool() const noexcept; constexpr reference& operator=(bool x) noexcept; constexpr reference& operator=(const reference& x) noexcept; constexpr const reference& operator=(bool x) const noexcept; + constexpr operator bool() const noexcept; constexpr void flip() noexcept; // flips the bit + + 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; }; // construct/copy/destroy @@ -10572,7 +10576,6 @@ constexpr void swap(vector&) noexcept(allocator_traits::propagate_on_container_swap::value || allocator_traits::is_always_equal::value); - static constexpr void swap(reference x, reference y) noexcept; constexpr void flip() noexcept; // flips all bits constexpr void clear() noexcept; }; @@ -10594,39 +10597,89 @@ \pnum \tcode{reference} -is a class that simulates the behavior of references of a single bit in -\tcode{vector}. The conversion function returns \tcode{true} -when the bit is set, and \tcode{false} otherwise. The assignment operators -set the bit when the argument is (convertible to) \tcode{true} and -clear it otherwise. \tcode{flip} reverses the state of the bit. +is a class that simulates a reference to a single bit in the sequence. -\indexlibrarymember{flip}{vector}% +\indexlibraryctor{vector::reference}% \begin{itemdecl} -constexpr void flip() noexcept; +constexpr reference::reference(const reference& x) noexcept; \end{itemdecl} \begin{itemdescr} \pnum \effects -Replaces each element in the container with its complement. +Initializes \tcode{*this} to refer to the same bit as \tcode{x}. +\end{itemdescr} + +\indexlibrarydtor{vector::reference}% +\begin{itemdecl} +constexpr reference::~reference(); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +None. \end{itemdescr} -\indexlibrarymember{swap}{vector}% +\indexlibrarymember{operator=}{vector::reference}% \begin{itemdecl} -static constexpr void swap(reference 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; \end{itemdecl} \begin{itemdescr} \pnum \effects -Exchanges the contents of \tcode{x} and \tcode{y} as if by: +Sets the bit referred to by \tcode{*this} when \tcode{bool(x)} is \tcode{true}, +and clears it otherwise. + +\pnum +\returns +\tcode{*this}. +\end{itemdescr} + +\indexlibrarymember{flip}{vector::reference}% +\begin{itemdecl} +constexpr void reference::flip() noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +Equivalent to \tcode{*this = !*this}. +\end{itemdescr} + +\indexlibrarymember{swap}{vector::reference}% +\begin{itemdecl} +constexpr void swap(reference x, reference y) noexcept; +constexpr void swap(reference x, bool& y) noexcept; +constexpr void swap(bool& x, reference y) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +Exchanges the values denoted by \tcode{x} and \tcode{y} as if by: \begin{codeblock} bool b = x; x = y; y = b; \end{codeblock} +\end{itemdescr} + + +\indexlibrarymember{flip}{vector}% +\begin{itemdecl} +constexpr void flip() noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +Replaces each element in the container with its complement. \end{itemdescr} \begin{itemdecl} diff --git a/source/future.tex b/source/future.tex index 60ebd4d2e5..8c51c8522a 100644 --- a/source/future.tex +++ b/source/future.tex @@ -636,6 +636,37 @@ \end{itemize} \end{itemdescr} +\rSec1[depr.vector.bool.swap]{Deprecated \tode{vector} swap} + +\pnum +The following member is declared in addition to those members specified in +\ref{vector.bool}: + +\begin{codeblock} +namespace std { + template class vector { + public: + static constexpr void swap(reference x, reference y) noexcept; + }; +} +\end{codeblock} + +\indexlibrarymember{swap}{vector}% +\begin{itemdecl} +static constexpr void swap(reference x, reference y) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +Exchanges the values denoted by \tcode{x} and \tcode{y} as if by: +\begin{codeblock} +bool b = x; +x = y; +y = b; +\end{codeblock} +\end{itemdescr} + \rSec1[depr.iterator]{Deprecated \tcode{iterator} class template} \pnum diff --git a/source/utilities.tex b/source/utilities.tex index a7975824a7..e0b3f0317f 100644 --- a/source/utilities.tex +++ b/source/utilities.tex @@ -10409,13 +10409,18 @@ // bit reference class reference { public: - constexpr reference(const reference&) = default; + constexpr reference(const reference& x) noexcept; constexpr ~reference(); constexpr reference& operator=(bool x) noexcept; // for \tcode{b[i] = x;} - constexpr reference& operator=(const reference&) noexcept; // for \tcode{b[i] = b[j];} - constexpr bool operator~() const noexcept; // flips the bit + constexpr reference& operator=(const reference& x) noexcept; // for \tcode{b[i] = b[j];} + constexpr const reference& operator=(bool x) const noexcept; constexpr operator bool() const noexcept; // for \tcode{x = b[i];} + constexpr bool operator~() const noexcept; // flips the bit constexpr reference& flip() noexcept; // for \tcode{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; }; // \ref{bitset.cons}, constructors @@ -10502,7 +10507,7 @@ zero. Each bit has a non-negative position \tcode{pos}. When converting -between an object of class +between an object of type \tcode{bitset} and a value of some integral type, bit position \tcode{pos} corresponds to the @@ -10511,6 +10516,84 @@ The integral value corresponding to two or more bits is the sum of their bit values. +\pnum +\tcode{reference} +is a class that simulates a reference to a single bit in the sequence. + +\indexlibraryctor{bitset::reference}% +\begin{itemdecl} +constexpr reference::reference(const reference& x) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +Initializes \tcode{*this} to refer to the same bit as \tcode{x}. +\end{itemdescr} + +\indexlibrarydtor{bitset::reference}% +\begin{itemdecl} +constexpr reference::~reference(); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +None. +\end{itemdescr} + +\indexlibrarymember{operator=}{bitset::reference}% +\begin{itemdecl} +constexpr reference& reference::operator=(bool x) noexcept; +constexpr reference& reference::operator=(const reference& x) noexcept; +constexpr const reference& reference::operator=(bool x) const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +Sets the bit referred to by \tcode{*this} if \tcode{bool(x)} is \tcode{true}, +and clears it otherwise. + +\pnum +\returns +\tcode{*this}. +\end{itemdescr} + +\indexlibrarymember{swap}{bitset::reference}% +\begin{itemdecl} +constexpr void swap(reference x, reference y) noexcept; +constexpr void swap(reference x, bool& y) noexcept; +constexpr void swap(bool& x, reference y) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +Exchanges the values denoted by \tcode{x} and \tcode{y} as if by: + +\begin{codeblock} +bool b = x; +x = y; +y = b; +\end{codeblock} +\end{itemdescr} + +\indexlibrarymember{flip}{bitset::reference}% +\begin{itemdecl} +constexpr reference& reference::flip() noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +Equivalent to \tcode{*this = !*this}. + +\pnum +\returns +\tcode{*this}. +\end{itemdescr} + \pnum The functions described in \ref{template.bitset} can report three kinds of errors, each associated with a distinct exception: