Skip to content

Commit ae946de

Browse files
committed
[template.bitset.general] Break out 'bitset::reference' into its own subclause
This change is consistent with specification of nested classes elsewhere in the standard, and allows better use of qualified names in the declaration of member functions in their own specification.
1 parent 4dc76ac commit ae946de

File tree

1 file changed

+69
-62
lines changed

1 file changed

+69
-62
lines changed

source/utilities.tex

Lines changed: 69 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -10533,22 +10533,8 @@
1053310533
namespace std {
1053410534
template<size_t N> class bitset {
1053510535
public:
10536-
// bit reference
10537-
class reference {
10538-
public:
10539-
constexpr reference(const reference& x) noexcept;
10540-
constexpr ~reference();
10541-
constexpr reference& operator=(bool x) noexcept; // for \tcode{b[i] = x;}
10542-
constexpr reference& operator=(const reference& x) noexcept; // for \tcode{b[i] = b[j];}
10543-
constexpr const reference& operator=(bool x) const noexcept;
10544-
constexpr operator bool() const noexcept; // for \tcode{x = b[i];}
10545-
constexpr bool operator~() const noexcept; // flips the bit
10546-
constexpr reference& flip() noexcept; // for \tcode{b[i].flip();}
10547-
10548-
friend constexpr void swap(reference x, reference y) noexcept;
10549-
friend constexpr void swap(reference x, bool& y) noexcept;
10550-
friend constexpr void swap(bool& x, reference y) noexcept;
10551-
};
10536+
// \ref{bitset.reference}, bit reference
10537+
class reference;
1055210538

1055310539
// \ref{bitset.cons}, constructors
1055410540
constexpr bitset() noexcept;
@@ -10625,6 +10611,8 @@
1062510611
\tcode{bitset<N>}
1062610612
describes an object that can store a sequence consisting of a fixed number of
1062710613
bits, \tcode{N}.
10614+
The class \tcode{bitset<N>::reference} simulates a reference
10615+
to a single bit in the sequence.
1062810616

1062910617
\pnum
1063010618
Each bit represents either the value zero (reset) or one (set).
@@ -10644,12 +10632,55 @@
1064410632
or more bits is the sum of their bit values.
1064510633

1064610634
\pnum
10647-
\tcode{reference}
10648-
is a class that simulates a reference to a single bit in the sequence.
10635+
The functions described in \ref{template.bitset} can report three kinds of
10636+
errors, each associated with a distinct exception:
10637+
\begin{itemize}
10638+
\item
10639+
an
10640+
\term{invalid-argument}
10641+
error is associated with exceptions of type
10642+
\tcode{invalid_argument}\iref{invalid.argument};
10643+
\indexlibraryglobal{invalid_argument}%
10644+
\item
10645+
an
10646+
\term{out-of-range}
10647+
error is associated with exceptions of type
10648+
\tcode{out_of_range}\iref{out.of.range};
10649+
\indexlibraryglobal{out_of_range}%
10650+
\item
10651+
an
10652+
\term{overflow}
10653+
error is associated with exceptions of type
10654+
\tcode{overflow_error}\iref{overflow.error}.
10655+
\indexlibraryglobal{overflow_error}%
10656+
\end{itemize}
10657+
10658+
\rSec3[bitset.reference]{Class \tcode{bitset<N>::reference}}%
10659+
\indexlibrarymember{reference}{bitset}%
10660+
\begin{codeblock}
10661+
namespace std {
10662+
template<size_t N>
10663+
class bitset<N>::reference {
10664+
public:
10665+
constexpr reference(const reference& x) noexcept;
10666+
constexpr ~reference();
10667+
constexpr reference& operator=(bool x) noexcept; // for \tcode{b[i] = x;}
10668+
constexpr reference& operator=(const reference& x) noexcept; // for \tcode{b[i] = b[j];}
10669+
constexpr const reference& operator=(bool x) const noexcept;
10670+
constexpr operator bool() const noexcept; // for \tcode{x = b[i];}
10671+
constexpr bool operator~() const noexcept; // flips the bit
10672+
constexpr reference& flip() noexcept; // for \tcode{b[i].flip();}
10673+
10674+
friend constexpr void swap(reference x, reference y) noexcept;
10675+
friend constexpr void swap(reference x, bool& y) noexcept;
10676+
friend constexpr void swap(bool& x, reference y) noexcept;
10677+
};
10678+
}
10679+
\end{codeblock}
1064910680

1065010681
\indexlibraryctor{bitset::reference}%
1065110682
\begin{itemdecl}
10652-
constexpr reference::reference(const reference& x) noexcept;
10683+
constexpr reference(const reference& x) noexcept;
1065310684
\end{itemdecl}
1065410685

1065510686
\begin{itemdescr}
@@ -10660,7 +10691,7 @@
1066010691

1066110692
\indexlibrarydtor{bitset::reference}%
1066210693
\begin{itemdecl}
10663-
constexpr reference::~reference();
10694+
constexpr ~reference();
1066410695
\end{itemdecl}
1066510696

1066610697
\begin{itemdescr}
@@ -10671,9 +10702,9 @@
1067110702

1067210703
\indexlibrarymember{operator=}{bitset::reference}%
1067310704
\begin{itemdecl}
10674-
constexpr reference& reference::operator=(bool x) noexcept;
10675-
constexpr reference& reference::operator=(const reference& x) noexcept;
10676-
constexpr const reference& reference::operator=(bool x) const noexcept;
10705+
constexpr reference& operator=(bool x) noexcept;
10706+
constexpr reference& operator=(const reference& x) noexcept;
10707+
constexpr const reference& operator=(bool x) const noexcept;
1067710708
\end{itemdecl}
1067810709

1067910710
\begin{itemdescr}
@@ -10687,6 +10718,21 @@
1068710718
\tcode{*this}.
1068810719
\end{itemdescr}
1068910720

10721+
\indexlibrarymember{flip}{bitset::reference}%
10722+
\begin{itemdecl}
10723+
constexpr reference& flip() noexcept;
10724+
\end{itemdecl}
10725+
10726+
\begin{itemdescr}
10727+
\pnum
10728+
\effects
10729+
Equivalent to \tcode{*this = !*this}.
10730+
10731+
\pnum
10732+
\returns
10733+
\tcode{*this}.
10734+
\end{itemdescr}
10735+
1069010736
\indexlibrarymember{swap}{bitset::reference}%
1069110737
\begin{itemdecl}
1069210738
constexpr void swap(reference x, reference y) noexcept;
@@ -10706,45 +10752,6 @@
1070610752
\end{codeblock}
1070710753
\end{itemdescr}
1070810754

10709-
\indexlibrarymember{flip}{bitset::reference}%
10710-
\begin{itemdecl}
10711-
constexpr reference& reference::flip() noexcept;
10712-
\end{itemdecl}
10713-
10714-
\begin{itemdescr}
10715-
\pnum
10716-
\effects
10717-
Equivalent to \tcode{*this = !*this}.
10718-
10719-
\pnum
10720-
\returns
10721-
\tcode{*this}.
10722-
\end{itemdescr}
10723-
10724-
\pnum
10725-
The functions described in \ref{template.bitset} can report three kinds of
10726-
errors, each associated with a distinct exception:
10727-
\begin{itemize}
10728-
\item
10729-
an
10730-
\term{invalid-argument}
10731-
error is associated with exceptions of type
10732-
\tcode{invalid_argument}\iref{invalid.argument};
10733-
\indexlibraryglobal{invalid_argument}%
10734-
\item
10735-
an
10736-
\term{out-of-range}
10737-
error is associated with exceptions of type
10738-
\tcode{out_of_range}\iref{out.of.range};
10739-
\indexlibraryglobal{out_of_range}%
10740-
\item
10741-
an
10742-
\term{overflow}
10743-
error is associated with exceptions of type
10744-
\tcode{overflow_error}\iref{overflow.error}.
10745-
\indexlibraryglobal{overflow_error}%
10746-
\end{itemize}
10747-
1074810755
\rSec3[bitset.cons]{Constructors}
1074910756

1075010757
\indexlibraryctor{bitset}%

0 commit comments

Comments
 (0)