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.
This commit is contained in:
parent
141f518bdd
commit
fae235197f
|
@ -64,6 +64,7 @@ AsBytes(std::string_view sv) noexcept
|
|||
* Cast a reference to a fixed-size std::span<const std::byte>.
|
||||
*/
|
||||
template<typename T>
|
||||
requires std::has_unique_object_representations_v<T>
|
||||
constexpr auto
|
||||
ReferenceAsBytes(const T &value) noexcept
|
||||
{
|
||||
|
@ -71,6 +72,7 @@ ReferenceAsBytes(const T &value) noexcept
|
|||
}
|
||||
|
||||
template<typename T>
|
||||
requires std::has_unique_object_representations_v<T>
|
||||
constexpr auto
|
||||
ReferenceAsWritableBytes(T &value) noexcept
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue