From a67d7239a46f6c65f14f3c90317888261a77732c Mon Sep 17 00:00:00 2001 From: kayomn Date: Mon, 20 Feb 2023 14:30:14 +0000 Subject: [PATCH] Implement core function to reinterpreting anything as bytes --- source/coral.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/source/coral.cpp b/source/coral.cpp index 7dcaf2a..bcf7085 100644 --- a/source/coral.cpp +++ b/source/coral.cpp @@ -461,6 +461,13 @@ export namespace coral { // Input/output operations. export namespace coral { + /** + * Returns `value` reinterpreted as a sequence of bytes. + */ + slice as_bytes(auto & value) { + return {reinterpret_cast(&value), sizeof(value)}; + } + /** * Compares `a` and `b`, returning the difference between them or `0` if they are identical. */