Implement core function to reinterpreting anything as bytes

This commit is contained in:
kayomn 2023-02-20 14:30:14 +00:00
parent 2cbd8d1f31
commit a67d7239a4
1 changed files with 7 additions and 0 deletions

View File

@ -461,6 +461,13 @@ export namespace coral {
// Input/output operations. // Input/output operations.
export namespace coral { export namespace coral {
/**
* Returns `value` reinterpreted as a sequence of bytes.
*/
slice<u8 const> as_bytes(auto & value) {
return {reinterpret_cast<u8 const *>(&value), sizeof(value)};
}
/** /**
* Compares `a` and `b`, returning the difference between them or `0` if they are identical. * Compares `a` and `b`, returning the difference between them or `0` if they are identical.
*/ */