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.
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 InputIterat开发者_Go百科or
?
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);
Yes, a pointer is an input iterator.
精彩评论