20#include "pw_span/span.h"
25using ByteSpan = span<std::byte>;
27using ConstByteSpan = span<const std::byte>;
44 static_assert(std::is_trivially_copyable_v<T>,
45 "cannot treat object as bytes: "
46 "copying bytes may result in an invalid object");
47 static_assert(std::has_unique_object_representations_v<T>,
48 "cannot treat object as bytes: "
49 "type includes indeterminate bytes which may leak information "
50 "or result in incorrect object hashing");
53 return pw::as_bytes(s);
70 static_assert(std::is_trivially_copyable_v<T>,
71 "cannot treat object as bytes: "
72 "copying bytes may result in an invalid object");
73 static_assert(std::has_unique_object_representations_v<T>,
74 "cannot treat object as bytes: "
75 "type includes indeterminate bytes which may leak information "
76 "or result in incorrect object hashing");
79 return pw::as_writable_bytes(s);
Definition: span_impl.h:235
The Pigweed namespace.
Definition: alignment.h:27
span< const std::byte, sizeof(T)> ObjectAsBytes(const T &obj)
Definition: span.h:43
span< std::byte, sizeof(T)> ObjectAsWritableBytes(T &obj)
Definition: span.h:69