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
81 changes: 67 additions & 14 deletions source/containers.tex
Original file line number Diff line number Diff line change
Expand Up @@ -10480,13 +10480,17 @@
// bit reference
class @\libmember{reference}{vector<bool>}@ {
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
Expand Down Expand Up @@ -10572,7 +10576,6 @@
constexpr void swap(vector&)
noexcept(allocator_traits<Allocator>::propagate_on_container_swap::value ||
allocator_traits<Allocator>::is_always_equal::value);
static constexpr void swap(reference x, reference y) noexcept;
constexpr void flip() noexcept; // flips all bits
constexpr void clear() noexcept;
};
Expand All @@ -10594,39 +10597,89 @@

\pnum
\tcode{reference}
is a class that simulates the behavior of references of a single bit in
\tcode{vector<bool>}. 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<bool>}%
\indexlibraryctor{vector<bool>::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<bool>::reference}%
\begin{itemdecl}
constexpr reference::~reference();
\end{itemdecl}

\begin{itemdescr}
\pnum
\effects
None.
\end{itemdescr}

\indexlibrarymember{swap}{vector<bool>}%
\indexlibrarymember{operator=}{vector<bool>::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<bool>::reference}%
\begin{itemdecl}
constexpr void reference::flip() noexcept;
\end{itemdecl}

\begin{itemdescr}
\pnum
\effects
Equivalent to \tcode{*this = !*this}.
\end{itemdescr}

\indexlibrarymember{swap}{vector<bool>::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<bool>}%
\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}
Expand Down
31 changes: 31 additions & 0 deletions source/future.tex
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,37 @@
\end{itemize}
\end{itemdescr}

\rSec1[depr.vector.bool.swap]{Deprecated \tode{vector<bool, Allocator>} swap}

\pnum
The following member is declared in addition to those members specified in
\ref{vector.bool}:

\begin{codeblock}
namespace std {
template<class Allocator> class vector<bool, Allocator> {
public:
static constexpr void swap(reference x, reference y) noexcept;
};
}
\end{codeblock}

\indexlibrarymember{swap}{vector<bool>}%
\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
Expand Down
91 changes: 87 additions & 4 deletions source/utilities.tex
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<N>}
and a value of some
integral type, bit position \tcode{pos} corresponds to the
Expand All @@ -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:
Expand Down
Loading