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
154 stars 12 forks source link

Add operator[] #18

Closed Neargye closed 4 years ago

Neargye commented 4 years ago

Thanks for the handy library!

It seems that it would be convenient to add the operator[] to access the elements. For example, std::span allows it.

Neargye commented 4 years ago

I add tests soon.

martinmoene commented 4 years ago

Thanks @Neargye,

Please note that ring_span lite is modeled after proposal p0059 and models a non-owning queue, not an indexable span-like view. Hence a user-accessible operator[](ndx) or at(ndx) is not present.

So, unless the ideas in the proposal change in this respect, operator[](ndx) or at(ndx) should be offered as an extension via nsrs_RING_SPAN_LITE_EXTENSION.

Generally I try to favour extensions as a way to enable collecting experience with them.

Remember to update the Readme.

Neargye commented 4 years ago

I have not forgotten anything? What is done:

martinmoene commented 4 years ago

Looks good to me, will merge, when Appveyor succeeds.