diff options
author | MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> | 2023-12-11 22:33:56 +0100 |
---|---|---|
committer | MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> | 2023-12-15 15:20:54 +0100 |
commit | fa898e6836a8fc2c7b6c8c15ad21818b16a89863 (patch) | |
tree | 67528e7f1366e6addf601d095c8c891e7758c304 /src/span.h | |
parent | 9776186e9f8ee00f912fc9d0ee8e634bb9401bfe (diff) | |
download | bitcoin-fa898e6836a8fc2c7b6c8c15ad21818b16a89863.tar.xz |
refactor: Print verbose serialize compiler error messages
Diffstat (limited to 'src/span.h')
-rw-r--r-- | src/span.h | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/span.h b/src/span.h index 2e8da27cde..2c27a54fc7 100644 --- a/src/span.h +++ b/src/span.h @@ -8,6 +8,7 @@ #include <algorithm> #include <cassert> #include <cstddef> +#include <span> #include <type_traits> #ifdef DEBUG @@ -283,13 +284,16 @@ Span<std::byte> MakeWritableByteSpan(V&& v) noexcept return AsWritableBytes(Span{std::forward<V>(v)}); } -// Helper functions to safely cast to unsigned char pointers. +// Helper functions to safely cast basic byte pointers to unsigned char pointers. inline unsigned char* UCharCast(char* c) { return reinterpret_cast<unsigned char*>(c); } inline unsigned char* UCharCast(unsigned char* c) { return c; } inline unsigned char* UCharCast(std::byte* c) { return reinterpret_cast<unsigned char*>(c); } inline const unsigned char* UCharCast(const char* c) { return reinterpret_cast<const unsigned char*>(c); } inline const unsigned char* UCharCast(const unsigned char* c) { return c; } inline const unsigned char* UCharCast(const std::byte* c) { return reinterpret_cast<const unsigned char*>(c); } +// Helper concept for the basic byte types. +template <typename B> +concept BasicByte = requires { UCharCast(std::span<B>{}.data()); }; // Helper function to safely convert a Span to a Span<[const] unsigned char>. template <typename T> constexpr auto UCharSpanCast(Span<T> s) -> Span<typename std::remove_pointer<decltype(UCharCast(s.data()))>::type> { return {UCharCast(s.data()), s.size()}; } |