public member class
<bitset>

std::bitset::reference

class reference;
類引用型別
此嵌入類是當應用於非 const 限定 bitset 物件時由 bitset::operator[] 返回的型別。它透過模擬對 bool 的引用的介面來訪問單個位。

其原型是
1
2
3
4
5
6
7
8
9
10
11
class bitset::reference {
  friend class bitset;
  reference();                                        // no public constructor
public:
  ~reference();
  operator bool() const;                              // convert to bool
  reference& operator= (bool x);                      // assign bool
  reference& operator= (const reference& x);          // assign bit
  reference& flip();                                  // flip bit value
  bool operator~() const;                             // return inverse value
}
1
2
3
4
5
6
7
8
9
10
11
class bitset::reference {
  friend class bitset;
  reference() noexcept;                               // no public constructor
public:
  ~reference();
  operator bool() const noexcept;                     // convert to bool
  reference& operator= (bool x) noexcept;             // assign bool
  reference& operator= (const reference& x) noexcept; // assign bit
  reference& flip() noexcept;                         // flip bit value
  bool operator~() const noexcept;                    // return inverse value
}