From 951716146fc288b60604ba1b93b34032f37a47d8 Mon Sep 17 00:00:00 2001 From: Lee Clagett Date: Tue, 19 Dec 2017 20:30:02 -0500 Subject: Remove is_pod trait, and replace with is_standard_layout requirement --- contrib/epee/include/memwipe.h | 16 ++++++---------- contrib/epee/include/span.h | 2 +- contrib/epee/include/string_tools.h | 9 ++++++++- 3 files changed, 15 insertions(+), 12 deletions(-) (limited to 'contrib/epee/include') diff --git a/contrib/epee/include/memwipe.h b/contrib/epee/include/memwipe.h index c3b4ce8ab..3864b3ebf 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 5660c09d1..ba44f8f79 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) -- cgit v1.2.3