Namespaces
Variants
Views
Actions

std::vector<bool>::reference

From cppreference.com
< cpp‎ | container‎ | vector bool
Revision as of 06:22, 2 December 2012 by P12 (Talk | contribs)

template <class Allocator>
class vector<bool, Allocator> {
  // ...
  public:
    class reference {
        friend class vector;
        reference();
      public:
        ~reference();
        operator bool() const;
        reference& operator=(bool x);
        reference& operator=(const reference&);
        void flip();
    };
  // ...
};

The std::vector<bool> specialization defines std::vector<bool>::reference as a publicly-accessible nested class. std::vector<bool>::reference proxies the behavior of references to a single bit in std::vector<bool>.

  • operator bool returns true when the bit is set.
  • The assignment operators set and clear the given bit.
  • flip inverts the state of the bit.

See also

Template:cpp/container/dcl list operator at