Namespaces
Variants
Views
Actions

std::bitset::reference

From cppreference.com
< cpp‎ | utility‎ | bitset
Revision as of 15:56, 2 November 2012 by P12bot (Talk | contribs)

template <size_t N>
class bitset {
  // ...
  public:
    class reference {
        friend class bitset;
        reference() noexcept;
      public:
        ~reference() noexcept;
        reference& operator=(bool x) noexcept;
        reference& operator=(const reference&) noexcept;
        bool operator~() const noexcept;
        operator bool() const noexcept;
        reference& flip() noexcept;
    };
  // ...
};

(noexcept specifications are from (C++11))

The bitset class includes std::bitset::reference as a publicly-accessible nested class. This class is used as a proxy object to allow users to interact with individual bits of a bitset, since standard C++ types (like references and pointers) are not built with enough precision to specify individual bits.

The primary use of std::bitset::reference is to provide an l-value that can be returned from operator[].

Any reads or writes to a bitset that happen via a std::bitset::reference potentially read or write to the entire underlying bitset.

See also

accesses specific bit
(public member function) [edit]