aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz>2024-12-18 15:36:27 +0100
committerMarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz>2024-12-19 14:40:32 +0100
commitfaa5391f77037601875cf4ed154bc42840d34b12 (patch)
tree456cf1f754c2a69fe0e6ec0bcc05eb79b355762b
parentfa86223475353cc994cc2563ba5aecc406d00815 (diff)
refactor: test: Return std::span from StringBytes
This is possible and safe, because std::span can implicitly convert into Span, if needed. Changing this function is required, because std::span requires the extent template parameter to be specified as well. Instead of explicilty specifying them, just let the compiler derive the template parameters correctly. Otherwise, there would be a compile error later on: src/wallet/test/db_tests.cpp:39:37: error: no matching function for call to ‘as_bytes<const char>(<brace-enclosed initializer list>)’ ... /usr/include/c++/11/span:420:5: note: candidate: ... | as_bytes(span<_Type, _Extent> __sp) noexcept | ^~~~~~~~ /usr/include/c++/11/span:420:5: note: template argument deduction/substitution failed: src/wallet/test/db_tests.cpp:39:37: note: couldn’t deduce template parameter ‘_Extent’ | return std::as_bytes<const char>({str.data(), str.size()}); | ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
-rw-r--r--src/wallet/test/db_tests.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/wallet/test/db_tests.cpp b/src/wallet/test/db_tests.cpp
index ea32199497..41951e84c8 100644
--- a/src/wallet/test/db_tests.cpp
+++ b/src/wallet/test/db_tests.cpp
@@ -34,9 +34,9 @@ inline std::ostream& operator<<(std::ostream& os, const std::pair<const Serializ
namespace wallet {
-static Span<const std::byte> StringBytes(std::string_view str)
+inline std::span<const std::byte> StringBytes(std::string_view str)
{
- return AsBytes<const char>({str.data(), str.size()});
+ return std::as_bytes(std::span{str});
}
static SerializeData StringData(std::string_view str)