mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-09 03:18:09 -03:00
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()}); | ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
This commit is contained in:
parent
fa86223475
commit
faa5391f77
1 changed files with 2 additions and 2 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue