From 4869db702afcda561abc9347b3c9d3060e9c5ac0 Mon Sep 17 00:00:00 2001 From: Lee Clagett Date: Mon, 31 Oct 2016 13:22:21 -0400 Subject: adding static_assert to pod functions in string tools --- contrib/epee/include/string_tools.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'contrib') 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 #include #include +#include //#include #include #include @@ -171,6 +172,7 @@ namespace string_tools template bool parse_tpod_from_hex_string(const std::string& str_hash, t_pod_type& t_pod) { + static_assert(std::is_pod::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 std::string pod_to_hex(const t_pod_type& s) { + static_assert(std::is_pod::value, "expected pod type"); std::string buff; buff.assign(reinterpret_cast(&s), sizeof(s)); return buff_to_hex_nodelimer(buff); @@ -578,6 +581,7 @@ POP_WARNINGS template bool hex_to_pod(const std::string& hex_str, t_pod_type& s) { + static_assert(std::is_pod::value, "expected pod type"); std::string hex_str_tr = trim(hex_str); if(sizeof(s)*2 != hex_str.size()) return false; -- cgit v1.2.3