SysTutorials

Linux Manual Pages › Section 3

stdvectorreference(3)

std::vector<bool>::reference – std::vector<bool>::reference

Synopsis

class reference;

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>.
The primary use of std::vector<bool>::reference is to provide an l-value that can be returned from operator[].
Any reads or writes to a vector that happen via a std::vector<bool>::reference potentially read or write to the entire underlying vector.

Member functions

              constructs the reference. Accessible only to std::vector<bool> itself
constructor (public member function)
              destroys the reference
destructor (public member function)
              assigns a bool to the referenced bit
operator= (public member function)
              returns the referenced bit
operator bool (public member function)
              flips the referenced bit
flip (public member function)

 std::vector<bool>::reference::~reference

~reference()

Destroys the reference.

 std::vector<bool>::reference::operator=

reference& operator=( bool x ); (until C++11)
reference& operator=( const reference& x );
reference& operator=( bool x ) noexcept; (since C++11)
reference& operator=( const reference& x ) noexcept;

Assigns a value to the referenced bit.

Parameters

x – value to assign

Return value

*this
 std::vector<bool>::reference::operator bool
operator bool() const; (until C++11)
operator bool() const noexcept; (since C++11)
Returns the value of the referenced bit.

Parameters

(none)

Return value

The referenced bit.
 std::vector<bool>::reference::flip

void flip();
(until C++ 11)
    void flip() noexcept;
(since C++ 11)

Inverts the referenced bit.

Parameters

(none)

Return value

(none)

See also

           access specified element
operator[] (public member function of std::vector<T,Allocator>)
swap swaps two std::vector<bool>::references
           (public static member function)
[static]