std::raw_storage_iterator
提供: cppreference.com
ヘッダ <memory> で定義 | ||
template<class OutputIt, class T > class raw_storage_iterator | (C++17未満) | |
template<class OutputIt, class T > class raw_storage_iterator; | (C++17以上) (非推奨) (C++20で削除) | |
出力イテレータ std::raw_storage_iterator
は標準アルゴリズムが未初期化メモリに結果を格納できるようにします。 アルゴリズムが逆参照したイテレータに T
型のオブジェクトを書き込むとき、オブジェクトはイテレータの指す未初期化記憶域の位置にコピー構築されます。 テンプレート引数 OutputIt
は、 LegacyOutputIterator を満たし、 T*
型のオブジェクトを返す operator& を持つオブジェクトを返す operator* を持つ、任意の型です。 通常、型 T*
が OutputIt
として使用されます。
目次 |
[編集]型の要件
-OutputIt は LegacyOutputIterator の要件を満たさなければなりません。 |
[編集]メンバ関数
新しい raw_storage_iterator を作成します (パブリックメンバ関数) | |
バッファ内の指す先の位置にオブジェクトを構築します (パブリックメンバ関数) | |
イテレータを逆参照します (パブリックメンバ関数) | |
イテレータを進めます (パブリックメンバ関数) | |
(C++17以上) | ラップされたイテレータへのアクセスを提供します (パブリックメンバ関数) |
[編集]メンバ型
メンバ型 | 定義 |
iterator_category | std::output_iterator_tag |
value_type | void |
difference_type | void |
pointer | void |
reference | void |
メンバ型 | (C++17未満) |
[編集]例
Run this code
#include <iostream>#include <string>#include <memory>#include <algorithm> int main(){conststd::string s[]={"This", "is", "a", "test", "."};std::string* p =std::allocator<std::string>().allocate(5); std::copy(std::begin(s), std::end(s), std::raw_storage_iterator<std::string*, std::string>(p)); for(std::string* i = p; i!=p+5;++i){std::cout<<*i <<'\n'; i->~basic_string<char>();}std::allocator<std::string>().deallocate(p, 5);}
出力:
This is a test .
[編集]関連項目
(C++11) | アロケータ型に関する情報を提供します (クラステンプレート) |
(C++11) | 多段コンテナのための多段アロケータを実装します (クラステンプレート) |
(C++11) | 指定された型がアロケータ使用構築をサポートしているかどうか調べます (クラステンプレート) |