Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding standard-conforming iterators for C++ #669

Open
madscientist opened this issue Sep 30, 2024 · 4 comments
Open

Adding standard-conforming iterators for C++ #669

madscientist opened this issue Sep 30, 2024 · 4 comments

Comments

@madscientist
Copy link
Contributor

A few months ago I added a standards-conforming iterator to the C++ interface for 32bit croaring. It's always frustrated me that the iterator support in the C++ interface isn't "right". For example, a conforming forward iterator needs to be an lvalue, but this means an iterator struct can't actually be empty/have no content. The "trick" of using a static "empty" iterator for end() also really bothers me as just "icky" :).

I find this page invaluable for considering iterator classes in C++: https://cplusplus.com/reference/iterator/

The iterators we have are kind of a mishmash of various things but the only type of iterator they actually fully implement is the simple input iterator. All other classes of iterator have something missing.

On the other hand, it's not clear to me that we can implement a "correct" STL iterator without any backward-compatibility issues with what's there now.

What are peoples' thoughts about this.

@lemire
Copy link
Member

lemire commented Oct 1, 2024

For header-only C++, we can always mix and match two behaviours... either through macros or some other means.

@lemire
Copy link
Member

lemire commented Oct 1, 2024

Also, we should precisely address what we mean by "backward-compatibility issues". Is it practically significant?

@madscientist
Copy link
Contributor Author

Well it won't be clear until the implementation is complete. A big part of that will be enhancing the tests for C++ iterators, which are currently a bit too minimal.. But what I was referring to would not just be an issue of recompiling the code or using a shared library. I am more concerned if code that currently uses iterators will have to change in some way. Maybe that won't be necessary. I agree the backward-compatibility situation needs to be clear in the commit message.

If this seems like something people are interested in I'll try to find time to polish my changes and put up a PR.

@lemire
Copy link
Member

lemire commented Oct 1, 2024

@madscientist I can't speak for everyone, but I can say that I would welcome progress on this front.

It is entirely possible that I am at the root of the problem you are trying to solve btw.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants