From 5b74a849cf5c54543280ba6488ae7f87361b1e2f Mon Sep 17 00:00:00 2001 From: l0rinc Date: Wed, 28 Aug 2024 13:28:25 +0200 Subject: [PATCH] util: Add consteval ""_hex[_v][_u8] literals ""_hex is a compile-time user-defined literal returning std::array, equivalent of ParseHex. Variants: - ""_hex_v returns std::vector - ""_hex_u8 returns std::array - ""_hex_v_u8 returns std::vector - Directly serializable as a size-prefixed OP_PUSH CScript payload using operator<<. Also extracts from_hex into shared util::ConstevalHexDigit function. Co-Authored-By: hodlinator <172445034+hodlinator@users.noreply.github.com> Co-Authored-By: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> Co-Authored-By: Ryan Ofsky Co-Authored-By: stickies-v --- src/test/util_tests.cpp | 29 ++++++++++++++++ src/uint256.h | 12 ++----- src/util/strencodings.h | 77 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 108 insertions(+), 10 deletions(-) diff --git a/src/test/util_tests.cpp b/src/test/util_tests.cpp index fbc8af789d5..1624fb8b5b6 100644 --- a/src/test/util_tests.cpp +++ b/src/test/util_tests.cpp @@ -7,6 +7,7 @@ #include // For Hash() #include // For CKey #include