Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 30 additions & 22 deletions source/containers.tex
Original file line number Diff line number Diff line change
Expand Up @@ -10489,21 +10489,8 @@
using reverse_iterator = std::reverse_iterator<iterator>;
using const_reverse_iterator = std::reverse_iterator<const_iterator>;

// bit reference
class @\libmember{reference}{vector<bool>}@ {
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()) { }
Expand Down Expand Up @@ -10607,13 +10594,34 @@
of \tcode{bool} values. A space-optimized representation of bits is
recommended instead.

\rSec3[vector.bool.reference]{Class \tcode{vector<bool>::reference}}%
\pnum
\tcode{reference}
is a class that simulates a reference to a single bit in the sequence.

\indexlibrarymember{reference}{vector<bool>}%
\begin{codeblock}
namespace std {
template<size_t N> class vector<bool>::reference {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please put the template-head on a separate line

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<bool>::reference}%
\begin{itemdecl}
constexpr reference::reference(const reference& x) noexcept;
constexpr reference(const reference& x) noexcept;
\end{itemdecl}

\begin{itemdescr}
Expand All @@ -10624,7 +10632,7 @@

\indexlibrarydtor{vector<bool>::reference}%
\begin{itemdecl}
constexpr reference::~reference();
constexpr ~reference();
\end{itemdecl}

\begin{itemdescr}
Expand All @@ -10635,9 +10643,9 @@

\indexlibrarymember{operator=}{vector<bool>::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}
Expand All @@ -10653,7 +10661,7 @@

\indexlibrarymember{flip}{vector<bool>::reference}%
\begin{itemdecl}
constexpr void reference::flip() noexcept;
constexpr void flip() noexcept;
\end{itemdecl}

\begin{itemdescr}
Expand Down Expand Up @@ -10681,7 +10689,7 @@
\end{codeblock}
\end{itemdescr}


\rSec3[vector.bool.members]{\tcode{vector<bool>} members}

\indexlibrarymember{flip}{vector<bool>}%
\begin{itemdecl}
Expand Down
130 changes: 68 additions & 62 deletions source/utilities.tex
Original file line number Diff line number Diff line change
Expand Up @@ -10533,22 +10533,8 @@
namespace std {
template<size_t N> 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;
Expand Down Expand Up @@ -10625,6 +10611,8 @@
\tcode{bitset<N>}
describes an object that can store a sequence consisting of a fixed number of
bits, \tcode{N}.
The class \tcode{bitset<N>::reference} simulates a reference
to a single bit in the sequence.

\pnum
Each bit represents either the value zero (reset) or one (set).
Expand All @@ -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<N>::reference}}%
\indexlibrarymember{reference}{bitset}%
\begin{codeblock}
namespace std {
template<size_t N> class bitset<N>::reference {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please put the template-head on a separate line.

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}
Expand All @@ -10660,7 +10690,7 @@

\indexlibrarydtor{bitset::reference}%
\begin{itemdecl}
constexpr reference::~reference();
constexpr ~reference();
\end{itemdecl}

\begin{itemdescr}
Expand All @@ -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}
Expand All @@ -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;
Expand All @@ -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}%
Expand Down