diff options
author | Riccardo Spagni <ric@spagni.net> | 2016-11-01 15:13:10 +0200 |
---|---|---|
committer | Riccardo Spagni <ric@spagni.net> | 2016-11-01 15:13:10 +0200 |
commit | 6f85b20d9206df2e6096ccfecb88ce2e9c6e4a45 (patch) | |
tree | 5c0cc61f5c268d8ea1b224615e49874d50ea036b /contrib | |
parent | Merge pull request #1282 (diff) | |
parent | adding static_assert to pod functions in string tools (diff) | |
download | monero-6f85b20d9206df2e6096ccfecb88ce2e9c6e4a45.tar.xz |
Merge pull request #1283
4869db7 adding static_assert to pod functions in string tools (Lee Clagett)
Diffstat (limited to '')
-rw-r--r-- | contrib/epee/include/string_tools.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/contrib/epee/include/string_tools.h b/contrib/epee/include/string_tools.h index b3623298c..6292e471c 100644 --- a/contrib/epee/include/string_tools.h +++ b/contrib/epee/include/string_tools.h @@ -33,6 +33,7 @@ #include <locale> #include <cstdlib> #include <iomanip> +#include <type_traits> //#include <strsafe.h> #include <boost/uuid/uuid.hpp> #include <boost/uuid/uuid_io.hpp> @@ -171,6 +172,7 @@ namespace string_tools template<class t_pod_type> bool parse_tpod_from_hex_string(const std::string& str_hash, t_pod_type& t_pod) { + static_assert(std::is_pod<t_pod_type>::value, "expected pod type"); std::string buf; bool res = epee::string_tools::parse_hexstr_to_binbuff(str_hash, buf); if (!res || buf.size() != sizeof(t_pod_type)) @@ -570,6 +572,7 @@ POP_WARNINGS template<class t_pod_type> std::string pod_to_hex(const t_pod_type& s) { + static_assert(std::is_pod<t_pod_type>::value, "expected pod type"); std::string buff; buff.assign(reinterpret_cast<const char*>(&s), sizeof(s)); return buff_to_hex_nodelimer(buff); @@ -578,6 +581,7 @@ POP_WARNINGS template<class t_pod_type> bool hex_to_pod(const std::string& hex_str, t_pod_type& s) { + static_assert(std::is_pod<t_pod_type>::value, "expected pod type"); std::string hex_str_tr = trim(hex_str); if(sizeof(s)*2 != hex_str.size()) return false; |