Name
vector<bool>::reference class — Bit reference proxy
Synopsis
class reference { friend class vector; reference( ); public: ~reference( ); operator bool( ) const; reference& operator=(const bool x); reference& operator=(const reference& x); void flip( ); };
The reference
class
represents a single bit in a vector<bool>
. The constructor is
private, so only vector<bool>
can create reference
objects. The reference
keeps track of the position of
an individual bit in a vector<bool>
, so you can get, set,
or flip the bit. The following are the members of reference
:
void
flip
( )
Flips or toggles the bit, that is, performs the equivalent of
*this
=
!
*this
operator
bool
( )
const
Returns the bit value as a
bool
reference&
operator=
(const bool x)
reference&
operator=
(const reference& x)
Assigns
x
to*this
See Also
Get C++ In a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.