Namespaces
Variants
Views
Actions

std::vector<bool>::reference

From cppreference.com
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.

[edit] See also

access specified element
(public member function of std::vector) [edit]