The Issue
I've read pointers are a type of an iterator and they can be used with the STL algorithms. Does that mean that they implement iterator traits?
I think not because the code
int a = 5, *p = &a;
std::cout << p.value_type << std::endl;
emits error: request for member ‘value_type’ in ‘p’, which is of non-class type ‘int*’
, which means that int*
isn't even a class.
Summary
- how are pointers used in STL algorithms without iterator traits?
- If pointers can go without implementing those, can I create a custom iterator that doesn't have iterator traits? (Do STL algorithms even use those traits?)
- When I use a pointer as an iterator, should I do something special to use it? (for example, define iterator traits...)