Commit 74d4ce76 authored by Dominik Charousset's avatar Dominik Charousset

Change result of string inspector to void

parent 1770bcd7
......@@ -45,18 +45,23 @@ namespace detail {
class stringification_inspector {
public:
using result_type = error;
// -- member types required by Inspector concept -----------------------------
using result_type = void;
using is_saving = std::true_type;
// -- constructors, destructors, and assignment operators --------------------
stringification_inspector(std::string& result) : result_(result) {
// nop
}
// -- operator() -------------------------------------------------------------
template <class... Ts>
error operator()(Ts&&... xs) {
void operator()(Ts&&... xs) {
traverse(std::forward<Ts>(xs)...);
return none;
}
private:
......
......@@ -37,6 +37,7 @@
#include "caf/meta/hex_formatted.hpp"
#include "caf/detail/comparable.hpp"
#include "caf/detail/scope_guard.hpp"
#include "caf/detail/type_traits.hpp"
namespace caf {
......@@ -140,15 +141,17 @@ public:
typename Inspector::result_type>
inspect(Inspector& f, node_id& x) {
data tmp;
auto result = f(meta::type_name("node_id"), tmp.pid_,
meta::hex_formatted(), tmp.host_);
// write changes to tmp back to x at scope exit
auto sg = detail::make_scope_guard([&] {
if (! tmp.valid())
x.data_.reset();
else if (! x || ! x.data_->unique())
x.data_.reset(new data(tmp));
else
*x.data_ = tmp;
return result;
});
return f(meta::type_name("node_id"), tmp.pid_,
meta::hex_formatted(), tmp.host_);
}
/// @endcond
......
......@@ -125,8 +125,8 @@ struct test_empty_non_pod {
};
template <class Inspector>
typename Inspector::result_type inspect(Inspector&, test_empty_non_pod&) {
return none;
typename Inspector::result_type inspect(Inspector& f, test_empty_non_pod&) {
return f();
}
class config : public actor_system_config {
......@@ -348,25 +348,6 @@ CAF_TEST(messages) {
CAF_CHECK(is_message(y).equal(i32, te, str, rs));
}
/*
CAF_TEST(actor_addr_via_message) {
auto testee = system.spawn([] {});
auto addr = actor_cast<actor_addr>(testee);
auto addr_msg = make_message(addr);
// serialize original message which uses tuple_vals and
// deserialize into a message which uses message builder
message x;
deserialize(serialize(addr_msg), x);
CAF_CHECK_EQUAL(to_string(addr_msg), to_string(x));
CAF_CHECK(is_message(x).equal(addr));
// serialize fully dynamic message again (do another roundtrip)
message y;
deserialize(serialize(x), y);
CAF_CHECK_EQUAL(to_string(addr_msg), to_string(y));
CAF_CHECK(is_message(y).equal(addr));
}
*/
CAF_TEST(multiple_messages) {
auto m = make_message(rs, te);
auto buf = serialize(te, m, msg);
......
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