-
Notifications
You must be signed in to change notification settings - Fork 62
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
Serialization. #916
Comments
Hi. Thanks for the suggestion. A similar question has been asked before in #401. That answer may help. Because they are class templates - and not strictly types themselves - it means that ability to serialise depends on the numeric type with which they are specialised. So if you specialise with an easily serialisable type, e.g. #include <iostream>
int main()
{
int n = 0x41424344;
std::cout.write(reinterpret_cast<char*>(&n), sizeof n) << '\n';
} should work just fine with #include <cnl/all.h>
#include <iostream>
int main()
{
cnl::scaled_integer<int, cnl::power<-16>> n = 16706.26275634765625;
std::cout.write(reinterpret_cast<char*>(&n), sizeof n) << '\n';
} (example) But if you use something non-trivial, e.g. a number type containing a pointer to dynamic memory, that's a bad idea! Action: add serialisation FAQ to front page. |
Thank you. This helps. |
You're welcome! Thanks for closing the issue. Ppl often don't. However, in this instance, I'm going to keep it open as a reminder to change the FAQ. After all, you're the second person to ask about it! |
What is the canonical way to serialize/deserialize CNL types?
Its not entirely clear how to access the underlying data structures from the documentation or construct cnl objects from raw bytes. a concise example would help, similar to existing examples.
What environment are you working in?
gcc 8+
The text was updated successfully, but these errors were encountered: