Commit 2709eb10 authored by Dominik Charousset's avatar Dominik Charousset

Allow using meta::hex_formatted for integer types

parent 6620e854
......@@ -19,11 +19,27 @@
#pragma once
#include <string>
#include <type_traits>
#include "caf/detail/type_traits.hpp"
namespace caf {
namespace detail {
void append_hex(std::string& result, const uint8_t* xs, size_t n);
template <class T>
enable_if_t<has_data_member<T>::value> append_hex(std::string& result,
const T& x) {
return append_hex(result, reinterpret_cast<const uint8_t*>(x.data()),
x.size());
}
template <class T>
enable_if_t<std::is_integral<T>::value> append_hex(std::string& result,
const T& x) {
return append_hex(result, reinterpret_cast<const uint8_t*>(&x), sizeof(T));
}
} // namespace detail
} // namespace caf
......@@ -276,8 +276,7 @@ public:
template <class T, class... Ts>
void traverse(const meta::hex_formatted_t&, const T& x, const Ts&... xs) {
sep();
append_hex(result_, reinterpret_cast<uint8_t*>(deconst(x).data()),
x.size());
append_hex(result_, x);
traverse(xs...);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment