首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

std::raw_storage_iterator

Defined in header <memory>

?

?

template< class OutputIt, class T > class raw_storage_iterator : public std::iterator<std::output_iterator_tag, void, void, void, void>;

?

(until C++17)

template< class OutputIt, class T > class raw_storage_iterator;

?

(since C++17) (deprecated)

输出迭代器std::raw_storage_iterator使标准算法能够将结果存储在未初始化的内存中。每当算法写入类型的对象时T对于取消引用的迭代器,对象被复制到迭代器所指向的未初始化存储中的位置。模板参数OutputIt是否符合OutputIterator而且有operator*定义为返回对象,其中operator&返回类型为T*.通常,类型T*被用作OutputIt...

类型要求

-输出必须符合输出器的要求。

*。

成员函数

(constructor)

creates a new raw_storage_iterator (public member function)

operator=

constructs an object at the pointed-to location in the buffer (public member function)

operator*

dereferences the iterator (public member function)

operator++operator++(int)

advances the iterator (public member function)

base (since C++17)

provides access to the wrapped iterator (public member function)

成员类型

Member type

Definition

value_type

void

difference_type

void

pointer

void

reference

void

iterator_category

std::output_iterator_tag

注意:在C++17之前,这些成员类型必须通过从std::iterator<std::output_iterator_tag,void,void,void,void>...

二次

代码语言:javascript
复制
#include <iostream>
#include <string>
#include <memory>
#include <algorithm>
 
int main()
{
    const std::string s[] = {"This", "is", "a", "test", "."};
    std::string* p = std::get_temporary_buffer<std::string>(5).first;
 
    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::return_temporary_buffer(p);
}

二次

产出:

二次

代码语言:javascript
复制
This
is
a
test
.

二次

另见

allocator_traits (C++11)

provides information about allocator types (class template)

scoped_allocator_adaptor (C++11)

implements multi-level allocator for multi-level containers (class template)

uses_allocator (C++11)

checks if the specified type supports uses-allocator construction (class template)

代码语言:txt
复制
 ? cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com