diff --git a/source/containers.tex b/source/containers.tex index 2a04fa0ef2..7193216c64 100644 --- a/source/containers.tex +++ b/source/containers.tex @@ -10489,21 +10489,8 @@ using reverse_iterator = std::reverse_iterator; using const_reverse_iterator = std::reverse_iterator; - // bit reference - class @\libmember{reference}{vector}@ { - public: - constexpr reference(const reference& x) noexcept; - constexpr ~reference(); - 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; - }; + // \ref{vector.bool.reference}, bit reference + class reference; // construct/copy/destroy constexpr vector() noexcept(noexcept(Allocator())) : vector(Allocator()) { } @@ -10607,13 +10594,34 @@ of \tcode{bool} values. A space-optimized representation of bits is recommended instead. +\rSec3[vector.bool.reference]{Class \tcode{vector::reference}}% \pnum \tcode{reference} is a class that simulates a reference to a single bit in the sequence. +\indexlibrarymember{reference}{vector}% +\begin{codeblock} +namespace std { + template class vector::reference { + public: + constexpr reference(const reference& x) noexcept; + constexpr ~reference(); + 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; + }; +} +\end{codeblock} + \indexlibraryctor{vector::reference}% \begin{itemdecl} -constexpr reference::reference(const reference& x) noexcept; +constexpr reference(const reference& x) noexcept; \end{itemdecl} \begin{itemdescr} @@ -10624,7 +10632,7 @@ \indexlibrarydtor{vector::reference}% \begin{itemdecl} -constexpr reference::~reference(); +constexpr ~reference(); \end{itemdecl} \begin{itemdescr} @@ -10635,9 +10643,9 @@ \indexlibrarymember{operator=}{vector::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; +constexpr reference& operator=(bool x) noexcept; +constexpr reference& operator=(const reference& x) noexcept; +constexpr const reference& operator=(bool x) const noexcept; \end{itemdecl} \begin{itemdescr} @@ -10653,7 +10661,7 @@ \indexlibrarymember{flip}{vector::reference}% \begin{itemdecl} -constexpr void reference::flip() noexcept; +constexpr void flip() noexcept; \end{itemdecl} \begin{itemdescr} @@ -10681,7 +10689,7 @@ \end{codeblock} \end{itemdescr} - +\rSec3[vector.bool.members]{\tcode{vector} members} \indexlibrarymember{flip}{vector}% \begin{itemdecl} diff --git a/source/utilities.tex b/source/utilities.tex index d714c1f2ef..3082249a83 100644 --- a/source/utilities.tex +++ b/source/utilities.tex @@ -10533,22 +10533,8 @@ namespace std { template class bitset { public: - // bit reference - class reference { - public: - constexpr reference(const reference& x) noexcept; - constexpr ~reference(); - constexpr reference& operator=(bool x) noexcept; // for \tcode{b[i] = x;} - 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.reference}, bit reference + class reference; // \ref{bitset.cons}, constructors constexpr bitset() noexcept; @@ -10625,6 +10611,8 @@ \tcode{bitset} describes an object that can store a sequence consisting of a fixed number of bits, \tcode{N}. +The class \tcode{bitset::reference} simulates a reference +to a single bit in the sequence. \pnum Each bit represents either the value zero (reset) or one (set). @@ -10644,12 +10632,54 @@ 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. +The functions described in \ref{template.bitset} can report three kinds of +errors, each associated with a distinct exception: +\begin{itemize} +\item +an +\term{invalid-argument} +error is associated with exceptions of type +\tcode{invalid_argument}\iref{invalid.argument}; +\indexlibraryglobal{invalid_argument}% +\item +an +\term{out-of-range} +error is associated with exceptions of type +\tcode{out_of_range}\iref{out.of.range}; +\indexlibraryglobal{out_of_range}% +\item +an +\term{overflow} +error is associated with exceptions of type +\tcode{overflow_error}\iref{overflow.error}. +\indexlibraryglobal{overflow_error}% +\end{itemize} + +\rSec3[bitset.reference]{Class \tcode{bitset::reference}}% +\indexlibrarymember{reference}{bitset}% +\begin{codeblock} +namespace std { + template class bitset::reference { + public: + constexpr reference(const reference& x) noexcept; + constexpr ~reference(); + constexpr reference& operator=(bool x) noexcept; // for \tcode{b[i] = x;} + 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; + }; +} +\end{codeblock} \indexlibraryctor{bitset::reference}% \begin{itemdecl} -constexpr reference::reference(const reference& x) noexcept; +constexpr reference(const reference& x) noexcept; \end{itemdecl} \begin{itemdescr} @@ -10660,7 +10690,7 @@ \indexlibrarydtor{bitset::reference}% \begin{itemdecl} -constexpr reference::~reference(); +constexpr ~reference(); \end{itemdecl} \begin{itemdescr} @@ -10671,9 +10701,9 @@ \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; +constexpr reference& operator=(bool x) noexcept; +constexpr reference& operator=(const reference& x) noexcept; +constexpr const reference& operator=(bool x) const noexcept; \end{itemdecl} \begin{itemdescr} @@ -10687,6 +10717,21 @@ \tcode{*this}. \end{itemdescr} +\indexlibrarymember{flip}{bitset::reference}% +\begin{itemdecl} +constexpr reference& flip() noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +Equivalent to \tcode{*this = !*this}. + +\pnum +\returns +\tcode{*this}. +\end{itemdescr} + \indexlibrarymember{swap}{bitset::reference}% \begin{itemdecl} constexpr void swap(reference x, reference y) noexcept; @@ -10706,45 +10751,6 @@ \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: -\begin{itemize} -\item -an -\term{invalid-argument} -error is associated with exceptions of type -\tcode{invalid_argument}\iref{invalid.argument}; -\indexlibraryglobal{invalid_argument}% -\item -an -\term{out-of-range} -error is associated with exceptions of type -\tcode{out_of_range}\iref{out.of.range}; -\indexlibraryglobal{out_of_range}% -\item -an -\term{overflow} -error is associated with exceptions of type -\tcode{overflow_error}\iref{overflow.error}. -\indexlibraryglobal{overflow_error}% -\end{itemize} - \rSec3[bitset.cons]{Constructors} \indexlibraryctor{bitset}%