From 35a996490200126e72775398fa3d6daa0ec4f435 Mon Sep 17 00:00:00 2001 From: Steven Le Rouzic Date: Wed, 13 Nov 2024 00:01:06 +0100 Subject: Introduce byte, use span on io Writer --- asl/span.hpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'asl/span.hpp') diff --git a/asl/span.hpp b/asl/span.hpp index e0db059..7135509 100644 --- a/asl/span.hpp +++ b/asl/span.hpp @@ -171,8 +171,26 @@ public: ASL_ASSERT(sub_size >= 0 && sub_size <= size()); return span{ data() + size() - sub_size, sub_size }; } - - // @Todo as_(mutable_)bytes }; +template +inline span as_bytes(span s) +{ + return span( + reinterpret_cast(s.data()), + s.size_bytes()); +} + +template +inline span as_mutable_bytes(span s) + requires (!is_const) +{ + return span( + reinterpret_cast(s.data()), + s.size_bytes()); +} + +template +span(T (&)[kSize]) -> span; + } // namespace asl -- cgit