Graeme
Graeme

Reputation: 4592

Random Access Iterator to char array

Is it possible to use std::iterator<std::random_access_iterator_tag, const char*> as an iterator over a char array? Looking at the std::iterator definition it only has default, copy and move constructors, no T constructor. Would this mean I'd need to inherit and implement my own iterator?

Upvotes: 0

Views: 1174

Answers (1)

Luc Danton
Luc Danton

Reputation: 35449

std::iterator can't help you as is. It's true that you could inherit from it to implement your own iterator, but you can already use pointers into the array as random-access iterators.

You can even use std::begin and std::end to get those iterators.

Upvotes: 4

Related Questions