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

Add std::span implementation #7553

Closed
wants to merge 3 commits into from
Closed

Add std::span implementation #7553

wants to merge 3 commits into from

Conversation

messmerd
Copy link
Member

This is a C++20 std::span implementation for C++17, plus a collection of compile-time unit tests.

This implementation of std::span does not include support for ranges (since we don't have ranges yet), but it does include the following extra features from later standards:

  • C++23: Const iterators
  • C++26: std::span over an initializer list P2447R6
  • C++26: std::span::at() P2821R5

@Rossmaxx
Copy link
Contributor

Sorry for being that guy but it would be better to wait till C++ 20 instead of rolling out our own implementation. Is there an urgent need to use span now?

@messmerd
Copy link
Member Author

messmerd commented Oct 21, 2024

Is there an urgent need to use span now?

Yes, this is something I'm using in the pin connector PR. I've moved it to this PR to make reviewing the pin connector easier once it's ready for review.

We probably won't be upgrading to C++20 within the next several months, and std::span is such an important vocabulary type to have, so I think rolling our own implementation is worth it. It is nearly identical to std::span so it should be trivial to swap it out for std::span when we do eventually upgrade to C++20.

@Rossmaxx
Copy link
Contributor

Ok then. I didn't thought of any upcoming improvements when I asked the question.

@messmerd messmerd closed this Oct 22, 2024
@messmerd
Copy link
Member Author

I'm closing this PR, because it looks like upgrading to C++20 will be much easier than I was anticipating.

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

Successfully merging this pull request may close these issues.

2 participants