diff --git a/contrib/epee/include/memwipe.h b/contrib/epee/include/memwipe.h index 6e50944e6..0d8f491b7 100644 --- a/contrib/epee/include/memwipe.h +++ b/contrib/epee/include/memwipe.h @@ -67,18 +67,14 @@ namespace tools { } }; + template + T& unwrap(scrubbed& src) { return src; } + + template + const T& unwrap(scrubbed const& src) { return src; } + template using scrubbed_arr = scrubbed>; } // namespace tools -// Partial specialization for std::is_pod> so that it can -// pretend to be the containted type in those contexts. -namespace std -{ - template - struct is_pod> { - static const bool value = is_pod::value; - }; -} - #endif // __cplusplus diff --git a/contrib/epee/include/span.h b/contrib/epee/include/span.h index 4273828d1..452cc088f 100644 --- a/contrib/epee/include/span.h +++ b/contrib/epee/include/span.h @@ -108,7 +108,7 @@ namespace epee template constexpr bool has_padding() noexcept { - return !std::is_pod::value || alignof(T) != 1; + return !std::is_standard_layout() || alignof(T) != 1; } //! \return Cast data from `src` as `span`. diff --git a/contrib/epee/include/string_tools.h b/contrib/epee/include/string_tools.h index 5a1ef0743..63705e401 100644 --- a/contrib/epee/include/string_tools.h +++ b/contrib/epee/include/string_tools.h @@ -45,6 +45,7 @@ #include #include #include "hex.h" +#include "memwipe.h" #include "span.h" #include "warnings.h" @@ -330,7 +331,7 @@ POP_WARNINGS template std::string pod_to_hex(const t_pod_type& s) { - static_assert(std::is_pod::value, "expected pod type"); + static_assert(std::is_standard_layout(), "expected standard layout type"); return to_hex::string(as_byte_span(s)); } //---------------------------------------------------------------------------- @@ -351,6 +352,12 @@ POP_WARNINGS return true; } //---------------------------------------------------------------------------- + template + bool hex_to_pod(const std::string& hex_str, tools::scrubbed& s) + { + return hex_to_pod(hex_str, unwrap(s)); + } + //---------------------------------------------------------------------------- bool validate_hex(uint64_t length, const std::string& str); //---------------------------------------------------------------------------- inline std::string get_extension(const std::string& str)