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

(De)serialize from C-style pointer without copy #35

Open
Peter-McLean-Altera opened this issue Mar 6, 2024 · 0 comments
Open

(De)serialize from C-style pointer without copy #35

Peter-McLean-Altera opened this issue Mar 6, 2024 · 0 comments

Comments

@Peter-McLean-Altera
Copy link

It is not always possible to use std::vector, std::array, or c_array[] style types. Right now, deserialization from raw pointer (uint8_t*) requires a copy.

example:

MyStruct raw_pointer_deserialize(const uint8_t* ptr) {
  std::error_code ec;
  return deserialize<MyStruct>((const uint8_t*)ptr, sizeof(MyStruct), ec);
}

A version of from_bytes with std::is_pointer on the container and runtime size passed in may be all that is needed.

@Peter-McLean-Altera Peter-McLean-Altera changed the title (De)serialize from C-style pointer (De)serialize from C-style pointer without copy Mar 6, 2024
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

1 participant