martinmoene / ring-span-lite

ring-span lite - A C++yy-like ring_span type for C++98, C++11 and later in a single-file header-only library
Boost Software License 1.0
148 stars 12 forks source link

Implement `operator->()` for iterators? #21

Closed Lyle-Alloy closed 3 years ago

Lyle-Alloy commented 3 years ago

Hey there,

I am not usually a C++ developer, but I was wondering if there was any reason that the -> operator is not implemented.

I have some code where I need to access some iterators in the context of a more complicated for loop and it would be very convenient.

It seems that some resources I've read about implementing iterators say to implement it, and some don't mention it.

Quuxplusone commented 3 years ago

FWIW, I suspect this was just an accidental omission in the original implementation, caused by P0059's not actually specifying the details of the iterator type (so I and/or Martin were making up the details as we went along). operator-> should be implemented.

(Technically, an iterator can be a C++20 std::random_access_iterator without supporting operator->, because Ranges is schizophrenic. But all standard-ish iterators should support operator-> as a matter of QoI.)

Lyle-Alloy commented 3 years ago

Cool! Thanks for teaching me a bit more about iterators as well.

Thanks for the great ring buffer implementation!

martinmoene commented 3 years ago

You're welcome, glad it's useful :)