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

etl::span: Add advance(), copy(), reinterpret_as() #1024

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

rolandreichweinbmw
Copy link

This commit adds to etl::span:

  • advance()
  • copy()
  • reinterpret_as()

including tests.

@jwellbelove
Copy link
Contributor

Is the purpose of reinterpret_as to map, for example, a buffer of char to a range of int, and the other way round?
Shouldn't there to be a check for size multiple and possibly alignment, so that, say, seven int8_t at an odd alignment cannot be reinterpreted as a unit32_t?

i.e.

etl::array<int8_t, 7> buffer;
etl::span<int8_t) sp1(buffer.begin(), buffer.end());
auto sp2 = sp1.reinterpret_as<unit32_t>();

uint32_t i = *sp2.begin(); // Is this aligned correctly!

@rolandreichweinbmw
Copy link
Author

Right. I will add this.

include/etl/span.h Outdated Show resolved Hide resolved
include/etl/span.h Outdated Show resolved Hide resolved
include/etl/span.h Outdated Show resolved Hide resolved
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