Skip to content

Fix exception/error state when using static_buffer with buffer_adaptor#33

Merged
Chaosvex merged 3 commits into
masterfrom
static_buffer_adaptor
Apr 5, 2025
Merged

Fix exception/error state when using static_buffer with buffer_adaptor#33
Chaosvex merged 3 commits into
masterfrom
static_buffer_adaptor

Conversation

@Chaosvex
Copy link
Copy Markdown
Member

@Chaosvex Chaosvex commented Apr 5, 2025

static_buffer wasn't previously usable with buffer_adaptor but the changes made to allow for writable std::arrays have made it compatible.

Due to the interface differences, using static_buffer with buffer_adaptor would throw an exception (or set the error state) since size() reports the number of readable bytes available, unlike std::array, where it's a capacity constant. This caused writing to static_buffer to fail with an out of space error.

Adding resize() allows buffer_adaptor to effectively advance the write cursor and use it as it would any other contiguous buffer.

There's no reason to use static_buffer with buffer_adaptor, but may as well fix it so it works.

@Chaosvex Chaosvex merged commit 4eac75a into master Apr 5, 2025
3 checks passed
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.

1 participant