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

nonstd::ring with a fixed array type as the container #33

Closed
Crzyrndm opened this issue May 15, 2024 · 4 comments
Closed

nonstd::ring with a fixed array type as the container #33

Crzyrndm opened this issue May 15, 2024 · 4 comments

Comments

@Crzyrndm
Copy link
Contributor

Crzyrndm commented May 15, 2024

ring type here being the owning buffer that wraps a container and a ring_span. Right now the ring type is unable to use a fixed size array as the backing container because the only constructor requires a capacity argument
https://github.com/martinmoene/ring-span-lite/blob/master/include/nonstd/ring.hpp#L51-L54

all that is required to support ring<std::array<T, N>> is conditionally adding a default ctor (I've made it conditional on not having a with_capacity ctor here)
https://github.com/Crzyrndm/ring-span-lite/blob/array-ctor/include/nonstd/ring.hpp#L52-L56`
Built in / C array support would probably only require changing .begin()/end() to std::begin/end

Not sure if that's the right condition to use but it's working for the moment

@Quuxplusone
Copy link

I have no meaningful opinion on the actual feature request, but I'll just leave this here: std::is_constructible_v<int[10], size_t> is true in C++20, because of paren-agg-init. https://quuxplusone.github.io/blog/2022/06/03/aggregate-parens-init-considered-kinda-bad/

@martinmoene
Copy link
Owner

@Crzyrndm Thanks for the heads-up.

Enabling the use of a C-array as template parameters requires some more work.

martinmoene added a commit that referenced this issue May 19, 2024
martinmoene added a commit that referenced this issue May 20, 2024
…tainer (#33, thanks @Crzyrndm)

Move definition of class ring into namespace `nsrs` and make it available in namespace `nonstd`.
@martinmoene
Copy link
Owner

@Crzyrndm C-array and std::array are now supported as the backing container.

So now one can write:

nonstd::ring< int[3] > r;
nonstd::ring< std::array<int, 3 >> s;

@martinmoene
Copy link
Owner

Completed.

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

3 participants