名前空間
変種
操作

std::vector<bool, Alloc>::reference

From cppreference.com
 
 
 
 
class reference;

std::vector<bool, Alloc> の特殊化は、公開アクセス可能なネストされたクラスとしてstd::vector<bool, Alloc>::reference を定義します。std::vector<bool, Alloc>::reference は、std::vector<bool, Alloc> 内の単一ビットへの参照の動作をプロキシします。

std::vector<bool, Alloc>::reference の主な用途は、operator[] から返される lvalue を提供することです。

std::vector<bool, Alloc>::reference を介して発生するベクトルへの読み取りまたは書き込みは、潜在的に基になるベクトルの全体に影響を与える可能性があります。

目次

[編集] メンバ関数

(コンストラクタ)
参照を作成します
(public member function)
(デストラクタ)
参照を破棄します
(public member function)
operator=
参照されているビットに値を代入します
(public member function)
operator bool
参照されているビットを返します
(public member function) [編集]
flip
参照されているビットを反転します
(public member function)

std::vector<bool, Alloc>::reference::reference

reference( const reference& ) = default;
(C++11以降)
(C++20 以降 constexpr)

別の参照から参照を作成します。 コピーコンストラクタは暗黙的に宣言されます。(C++11まで)

その他のコンストラクタは、std::vector<bool, Alloc> からのみアクセスできます。

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

~reference();
(C++20 以降 constexpr)

参照を破棄します。

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

reference& operator=( bool x );
(1) (C++11 以降 noexcept)
(C++20 以降 constexpr)
constexpr const reference& operator=( bool x ) const noexcept;
(2) (C++23から)
reference& operator=( const reference& x );
(3) (C++11 以降 noexcept)
(C++20 以降 constexpr)

参照されているビットに値を代入します。

パラメータ

x - 代入する値

戻り値

*this

std::vector<bool, Alloc>::reference::operator bool

operator bool() const;
(C++11 以降 noexcept)
(C++20 以降 constexpr)

参照されているビットの値を返します。

戻り値

参照されているビット。

std::vector<bool, Alloc>::reference::flip

void flip();
(C++11 以降 noexcept)
(C++20 以降 constexpr)

参照されているビットを反転します。

[編集] ヘルパークラス

std::formatter<std::vector<bool, Alloc>::reference>

template< class T, class CharT >

  requires /*is-vector-bool-reference*/<T>

struct formatter<T, CharT>;
(C++23から)

std::vector<bool, Alloc>::referencestd::formatter を特殊化します。この特殊化は、参照されているビットをフォーマットされる bool に変換してフォーマットする、基になるフォーマッタ(underlying_ と表記)として std::formatter<bool, CharT> を使用します。

公開専用定数 /*is-vector-bool-reference*/<T> は、T が任意の型 Alloc に対する std::vector<bool, Alloc>::reference 型を示し、かつ std::vector<bool, Alloc>プログラム定義の特殊化ではない場合にのみ true です。

メンバ関数

template< class ParseContext >
constexpr ParseContext::iterator parse( ParseContext& ctx );
(1) (C++23から)
template< class FormatContext >
FormatContext::iterator format( const T& r, FormatContext& ctx ) const;
(2) (C++23から)
1) return underlying_.parse(ctx); と同等です。
2) return underlying_.format(r, ctx); と同等です。

[編集]

[編集] 関連項目

指定された要素にアクセスする
(std::vector<T,Allocator> の public member function) [編集]
[static]
2つのstd::vector<bool>::reference を交換します
(public static member function) [編集]

[編集] 外部リンク

"Effective Modern C++" by Scott Meyers (2015), Chapter 2, Item 6: "Use the explicitly typed initializer idiom when auto deduces undesired types." (p.43-46) — プロキシクラスstd::vector<bool>::reference の誤用について説明しています。
English 日本語 中文(简体) 中文(繁體)