Name

bitset::reference class — Proxy class for a bit in a bitset

Synopsis

class reference {
  friend class bitset;
  reference(  )
public:
  ~reference(  );
  reference& operator=(bool x);
  reference& operator=(const reference&);
  bool operator~(  ) const;
  operator bool(  ) const;
  reference& flip(  );
};

The bitset::reference class is a proxy that refers to a single bit in a bitset. The constructor is private, so instances can be created only by the bitset class, particularly by its operator[] function. The member functions are:

reference& operator= (bool x)reference& operator= (const reference& x)

Sets the referenced bit to x in the underlying bitset. Returns *this.

bool operator~ ( ) const

Returns the logical negation of the referenced bit.

operator bool ( ) const

Returns the value of the referenced bit.

reference& flip ( )

Toggles the referenced bit in the underlying bitset. Returns *this.

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.