简体   繁体   English

std :: vector,元素指针和输入插入器

[英]std::vector, element pointer and input interator

I don't have my copy of Meyer's Effective C++ with me, so please forgive the question. 我没有我的Meyer的有效C ++副本,所以请原谅。

template <class InputIterator>
    void insert ( iterator position, InputIterator first, InputIterator last );

For vector's insert , is a byte* to a raw memory block a valid InputIterator ? 对于vector的insert ,原始内存块的字节*是有效的InputIterator吗?

typedef unsigned char byte;
vector<byte> my_vector;

byte my_data[NNN];
const byte* first = my_data;
const byte* last = my_data + COUNTOF(my_data);

my_vector.insert(my_vector.end(), first, last);

是的,指针是输入迭代器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM