From fae235197fe07f62c786c64129c45071a30ba400 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 16 Apr 2024 12:31:44 +0200 Subject: [PATCH] util/SpanCast: allow ReferenceAsBytes() only with trivially-copyable Addd the std::has_unique_object_representations_v constraint so we cast stuff to std::byte only if this would make sense. --- src/util/SpanCast.hxx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/util/SpanCast.hxx b/src/util/SpanCast.hxx index 10d45062c..27582433b 100644 --- a/src/util/SpanCast.hxx +++ b/src/util/SpanCast.hxx @@ -64,6 +64,7 @@ AsBytes(std::string_view sv) noexcept * Cast a reference to a fixed-size std::span. */ template +requires std::has_unique_object_representations_v constexpr auto ReferenceAsBytes(const T &value) noexcept { @@ -71,6 +72,7 @@ ReferenceAsBytes(const T &value) noexcept } template +requires std::has_unique_object_representations_v constexpr auto ReferenceAsWritableBytes(T &value) noexcept {