std::raw_storage_iterator - cppreference.com
提供: cppreference.com
<tbody> </tbody> <tbody class="t-dcl-rev "> </tbody><tbody> </tbody>
| ヘッダ |
||
|
|
(C++17未満) | |
|
|
(C++17以上) (非推奨) (C++20で削除) |
|
出力イテレータ std::raw_storage_iterator は標準アルゴリズムが未初期化メモリに結果を格納できるようにします。 アルゴリズムが逆参照したイテレータに T 型のオブジェクトを書き込むとき、オブジェクトはイテレータの指す未初期化記憶域の位置にコピー構築されます。 テンプレート引数 OutputIt は、 LegacyOutputIterator を満たし、 T* 型のオブジェクトを返す operator& を持つオブジェクトを返す operator* を持つ、任意の型です。 通常、型 T* が OutputIt として使用されます。
型の要件
メンバ関数
メンバ型
| メンバ型 | 定義 |
iterator_category
|
std::output_iterator_tag
|
value_type
|
void
|
difference_type
|
void
|
pointer
|
void
|
reference
|
void
|
|
メンバ型 |
(C++17未満) |
例
#include <iostream> #include <string> #include <memory> #include <algorithm> int main() { const std::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); }
出力: