Commit b52c9432 authored by Dominik Charousset's avatar Dominik Charousset

Fix maybe-uninitialized warnings

parent 667e1828
...@@ -176,7 +176,7 @@ public: ...@@ -176,7 +176,7 @@ public:
lhs = static_cast<underlying>(rhs); lhs = static_cast<underlying>(rhs);
} }
} assign; } assign;
underlying tmp; underlying tmp = 0;
return convert_apply(dref(), x, tmp, assign); return convert_apply(dref(), x, tmp, assign);
} }
......
...@@ -228,22 +228,49 @@ CAF_TEST(stringification_inspector) { ...@@ -228,22 +228,49 @@ CAF_TEST(stringification_inspector) {
} }
namespace { namespace {
template <class T>
struct is_integral_or_enum {
static constexpr bool value = std::is_integral<T>::value
|| std::is_enum<T>::value;
};
struct binary_serialization_policy { struct binary_serialization_policy {
execution_unit& context; execution_unit& context;
template <class T> template <class T>
bool operator()(T& x) { std::vector<char> to_buf(const T& x) {
std::vector<char> buf; std::vector<char> result;
binary_serializer f{&context, buf}; binary_serializer f{&context, result};
f(x); if (auto err = f(x))
binary_deserializer g{&context, buf}; CAF_FAIL("failed to serialize " << x << ": " << err);
return result;
}
template <class T>
detail::enable_if_t<is_integral_or_enum<T>::value, bool> operator()(T& x) {
auto buf = to_buf(x);
binary_deserializer f{&context, buf};
auto y = static_cast<T>(0);
if (auto err = f(y))
CAF_FAIL("failed to deserialize from buffer: " << err);
CAF_CHECK_EQUAL(x, y);
return detail::safe_equal(x, y);
}
template <class T>
detail::enable_if_t<!is_integral_or_enum<T>::value, bool> operator()(T& x) {
auto buf = to_buf(x);
binary_deserializer f{&context, buf};
T y; T y;
g(y); if (auto err = f(y))
CAF_FAIL("failed to deserialize from buffer: " << err);
CAF_CHECK_EQUAL(x, y); CAF_CHECK_EQUAL(x, y);
return detail::safe_equal(x, y); return detail::safe_equal(x, y);
} }
}; };
} // namespace <anonymous>
} // namespace
CAF_TEST(binary_serialization_inspectors) { CAF_TEST(binary_serialization_inspectors) {
actor_system_config cfg; actor_system_config cfg;
......
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