scoped_allocator_adaptor クラス
アロケーターの入れ子を表します。
構文
template <class Outer, class... Inner>
class scoped_allocator_adaptor;
解説
このクラス テンプレートは、1 つまたは複数のアロケーターの入れ子をカプセル化します。 このような各クラスは、outer_allocator_type 型の最も外側のアロケーターである Outer のシノニムを持ちます。これは、scoped_allocator_adaptor オブジェクトのパブリック ベースです。 Outer はコンテナーで使用されるメモリの割り当てに使用されます。 このアロケーター基本オブジェクトへの参照を取得するには、outer_allocator を呼び出します。
入れ子の残りの部分には inner_allocator_type 型が含まれます。 内部のアロケーターを使用して、コンテナー内の要素にメモリを割り当てます。 格納されているこの型のオブジェクトへの参照を取得するには、inner_allocator を呼び出します。 空でない場合 Inner... は、 inner_allocator_type 型 scoped_allocator_adaptor<Inner...>を持ち、 inner_allocator メンバー オブジェクトを指定します。 それ以外の場合、inner_allocator_type は型 scoped_allocator_adaptor<Outer> を持ち、inner_allocator はオブジェクト全体を指定します。
入れ子は、必要に応じて、最も内側のカプセル化されたアロケーターをレプリケートする任意の深さがあるかのように動作します。
このクラス テンプレートの動作を記述する上で、目に見えるインターフェイスの一部ではないいくつかの概念。 最も外側のアロケーターは、コンストラクトのすべての呼び出しを仲介し、メソッドを破棄します。 これは再帰関数 OUTERMOST(X)によって効果的に定義されます。ここで OUTERMOST(X) 、次のいずれかです。
X.outer_allocator()が整形式である場合、OUTERMOST(X)はOUTERMOST(X.outer_allocator())です。それ以外の場合、
OUTERMOST(X)はXです。
説明のために 3 つの型が定義されています。
| Type | 説明 |
|---|---|
Outermost |
OUTERMOST(*this) の型。 |
Outermost_traits |
allocator_traits<Outermost> |
Outer_traits |
allocator_traits<Outer> |
コンストラクター
| 名前 | 説明 |
|---|---|
| scoped_allocator_adaptor | scoped_allocator_adaptor オブジェクトを構築します。 |
Typedefs
| 名前 | 説明 |
|---|---|
const_pointer |
この型は、アロケーター Outer に関連付けられている const_pointer のシノニムです。 |
const_void_pointer |
この型は、アロケーター Outer に関連付けられている const_void_pointer のシノニムです。 |
difference_type |
この型は、アロケーター Outer に関連付けられている difference_type のシノニムです。 |
inner_allocator_type |
この型は、入れ子になったアダプター scoped_allocator_adaptor<Inner...> の型のシノニムです。 |
outer_allocator_type |
この型は、基本アロケーター Outer の型のシノニムです。 |
pointer |
この型は、アロケーター Outer に関連付けられている pointer のシノニムです。 |
propagate_on_container_copy_assignment |
Outer_traits::propagate_on_container_copy_assignment が true を保持するか、または inner_allocator_type::propagate_on_container_copy_assignment が true を保持する場合にのみ、この型は true を保持します。 |
propagate_on_container_move_assignment |
Outer_traits::propagate_on_container_move_assignment が true を保持するか、または inner_allocator_type::propagate_on_container_move_assignment が true を保持する場合にのみ、この型は true を保持します。 |
propagate_on_container_swap |
Outer_traits::propagate_on_container_swap が true を保持するか、または inner_allocator_type::propagate_on_container_swap が true を保持する場合にのみ、この型は true を保持します。 |
size_type |
この型は、アロケーター Outer に関連付けられている size_type のシノニムです。 |
value_type |
この型は、アロケーター Outer に関連付けられている value_type のシノニムです。 |
void_pointer |
この型は、アロケーター Outer に関連付けられている void_pointer のシノニムです。 |
構造体
| 名前 | 説明 |
|---|---|
| scoped_allocator_adaptor::rebind 構造体 | scoped_allocator_adaptor\<Other, Inner...> のシノニムとして Outer::rebind\<Other>::other 型を定義します。 |
メソッド
| 名前 | 説明 |
|---|---|
| allocate | Outer アロケーターを使用してメモリを割り当てます。 |
| construct | オブジェクトを構築します。 |
| deallocate | 外側のアロケーターを使用してオブジェクトの割り当てを解除します。 |
| destroy | 指定したオブジェクトを破棄します。 |
| inner_allocator | inner_allocator_type 型の格納されているオブジェクトへの参照を取得します。 |
| max_size | 外側のアロケーターが割り当てることができるオブジェクトの最大数を指定します。 |
| outer_allocator | outer_allocator_type 型の格納されているオブジェクトへの参照を取得します。 |
| select_on_container_copy_construction | 対応するアロケーターごとに select_on_container_copy_construction を呼び出すことによって、格納されている各アロケーター オブジェクトが初期化された新しい scoped_allocator_adaptor オブジェクトを作成します。 |
演算子
| 演算子 | 説明 |
|---|---|
| operator= | |
| operator== | |
| operator!= |
要件
ヘッダー:<scoped_allocator>
名前空間: std
scoped_allocator_adaptor::allocate
Outer アロケーターを使用してメモリを割り当てます。
pointer allocate(size_type count);pointer allocate(size_type count, const_void_pointer hint);
パラメーター
count
十分な記憶域を割り当てる要素の数。
hint
要求の前に割り当てられたオブジェクトのアドレスを見つけることによって、アロケーター オブジェクトを支援できるポインター。
戻り値
最初のメンバー関数は Outer_traits::allocate(outer_allocator(), count) を返します。 2 番目のメンバー関数は Outer_traits::allocate(outer_allocator(), count, hint) を返します。
scoped_allocator_adaptor::construct
オブジェクトを構築します。
template <class Ty, class... Atypes>
void construct(Ty* ptr, Atypes&&... args);
template <class Ty1, class Ty2, class... Atypes1, class... Atypes2>
void construct(pair<Ty1, Ty2>* ptr, piecewise_construct_t,
tuple<Atypes1&&...>
first, tuple<Atypes1&&...> second);
template <class Ty1, class Ty2>
void construct(pair<Ty1, Ty2>* ptr);
template <class Ty1, class Ty2, class Uy1, class Uy2>
void construct(pair<Ty1, Ty2>* ptr,
class Uy1&& first, class Uy2&& second);
template <class Ty1, class Ty2, class Uy1, class Uy2>
void construct(pair<Ty1, Ty2>* ptr, const pair<Uy1, Uy2>& right);
template <class Ty1, class Ty2, class Uy1, class Uy2>
void construct(pair<Ty1, Ty2>* ptr, pair<Uy1, Uy2>&& right);
パラメーター
ptr
オブジェクトが構築されるメモリの場所へのポインター。
args
引数リスト。
first
ペアの最初の型のオブジェクト。
second
ペアの 2 番目の型のオブジェクト。
right
移動またはコピーされる既存のオブジェクト。
注釈
Outermost_traits::construct(OUTERMOST(*this), ptr, xargs...) を呼び出して、最初のメソッドで ptr にオブジェクトを構築します。ここで xargs... は、次のいずれかです。
uses_allocator<Ty, inner_allocator_type>が false を保持する場合、xargs...はargs...です。uses_allocator<Ty, inner_allocator_type>が true を保持し、is_constructible<Ty, allocator_arg_t, inner_allocator_type, args...>が true を保持する場合、xargs...はallocator_arg, inner_allocator(), args...です。uses_allocator<Ty, inner_allocator_type>が true を保持し、is_constructible<Ty, args..., inner_allocator()>が true を保持する場合、xargs...はargs..., inner_allocator()です。
2 番目のメソッドは ptr でア オブジェクトを構築します。これは、Outermost_traits::construct(OUTERMOST(*this), &ptr->first, xargs...) を呼び出します。ここで、xargs... は前出のリストのように変更された first... であり、Outermost_traits::construct(OUTERMOST(*this), &ptr->second, xargs...) です。ここで、xargs... は前出のリストのように変更された second... です。
3 番目のメソッドの動作は this->construct(ptr, piecewise_construct, tuple<>, tuple<>) と同じです。
4 番目のメソッドの動作は this->construct(ptr, piecewise_construct, forward_as_tuple(std::forward<Uy1>(first), forward_as_tuple(std::forward<Uy2>(second)) と同じです。
5 番目のメソッドの動作は this->construct(ptr, piecewise_construct, forward_as_tuple(right.first), forward_as_tuple(right.second)) と同じです。
6 番目のメソッドの動作は this->construct(ptr, piecewise_construct, forward_as_tuple(std::forward<Uy1>(right.first), forward_as_tuple(std::forward<Uy2>(right.second)) と同じです。
scoped_allocator_adaptor::deallocate
外側のアロケーターを使用してオブジェクトの割り当てを解除します。
void deallocate(pointer ptr, size_type count);
パラメーター
ptr
割り当てを解除されるオブジェクトの開始位置へのポインター。
count
割り当てを解除するオブジェクトの数。
scoped_allocator_adaptor::destroy
指定したオブジェクトを破棄します。
template <class Ty>
void destroy(Ty* ptr)
パラメーター
ptr
破棄するオブジェクトへのポインター。
戻り値
Outermost_traits::destroy(OUTERMOST(*this), ptr)
scoped_allocator_adaptor::inner_allocator
inner_allocator_type 型の格納されているオブジェクトへの参照を取得します。
inner_allocator_type& inner_allocator() noexcept;
const inner_allocator_type& inner_allocator() const noexcept;
戻り値
inner_allocator_type 型の格納されているオブジェクトへの参照。
scoped_allocator_adaptor::max_size
外側のアロケーターが割り当てることができるオブジェクトの最大数を指定します。
size_type max_size();
戻り値
Outer_traits::max_size(outer_allocator())
scoped_allocator_adaptor::operator=
scoped_allocator_adaptor& operator=(const scoped_allocator_adaptor&) = default;
scoped_allocator_adaptor& operator=(scoped_allocator_adaptor&&) = default;
scoped_allocator_adaptor::operator==
template <class OuterA1, class OuterA2, class... InnerAllocs>
bool operator==(const scoped_allocator_adaptor<OuterA1, InnerAllocs...>& a,
const scoped_allocator_adaptor<OuterA2, InnerAllocs...>& b) noexcept;
scoped_allocator_adaptor::operator!=
template <class OuterA1, class OuterA2, class... InnerAllocs>
bool operator!=(const scoped_allocator_adaptor<OuterA1, InnerAllocs...>& a,
const scoped_allocator_adaptor<OuterA2, InnerAllocs...>& b) noexcept;
scoped_allocator_adaptor::outer_allocator
outer_allocator_type 型の格納されているオブジェクトへの参照を取得します。
outer_allocator_type& outer_allocator() noexcept;
const outer_allocator_type& outer_allocator() const noexcept;
戻り値
outer_allocator_type 型の格納されているオブジェクトへの参照。
scoped_allocator_adaptor::rebind 構造体
scoped_allocator_adaptor\<Other, Inner...> のシノニムとして Outer::rebind\<Other>::other 型を定義します。
struct rebind{ typedef Other_traits::rebind<Other> Other_alloc; typedef scoped_allocator_adaptor<Other_alloc, Inner...> other; };
scoped_allocator_adaptor::scoped_allocator_adaptor コンストラクター
scoped_allocator_adaptor オブジェクトを構築します。 デストラクターも含まれています。
scoped_allocator_adaptor();
scoped_allocator_adaptor(const scoped_allocator_adaptor& right) noexcept;
template <class Outer2>
scoped_allocator_adaptor(
const scoped_allocator_adaptor<Outer2, Inner...>& right) noexcept;
template <class Outer2>
scoped_allocator_adaptor(
scoped_allocator_adaptor<Outer2, Inner...>&& right) noexcept;
template <class Outer2>
scoped_allocator_adaptor(Outer2&& al,
const Inner&... rest) noexcept;
~scoped_allocator_adaptor();
パラメーター
right
既存の scoped_allocator_adaptor。
al
外側のアロケーターとして使用する既存のアロケーター。
rest
内側のアロケーターとして使用するアロケーターのリスト。
注釈
1 番目のコンストラクターは、格納されているアロケーター オブジェクトを既定で構築します。 次の 3 つのコンストラクターは、それぞれ right 内の対応するオブジェクトから、格納されているアロケーター オブジェクトを構築します。 最後のコンストラクターは、引数リストの対応する引数から、格納されているアロケーター オブジェクトを構築します。
scoped_allocator_adaptor::select_on_container_copy_construction
対応するアロケーターごとに select_on_container_copy_construction を呼び出すことによって、格納されている各アロケーター オブジェクトが初期化された新しい scoped_allocator_adaptor オブジェクトを作成します。
scoped_allocator_adaptor select_on_container_copy_construction();
戻り値
このメソッドは、実質的に scoped_allocator_adaptor(Outer_traits::select_on_container_copy_construction(*this), inner_allocator().select_on_container_copy_construction()) を返します。 結果は、対応するアロケーター al に対して al.select_on_container_copy_construction() を呼び出すことによって、格納されている各アロケーター オブジェクトが初期化された新しい scoped_allocator_adaptor オブジェクトです。