Commit 3d2d8690 authored by Dominik Charousset's avatar Dominik Charousset

Fix compiler errors and wanings on GCC 4.9

parent 236bf701
...@@ -27,7 +27,7 @@ struct foo { ...@@ -27,7 +27,7 @@ struct foo {
// foo needs to be serializable // foo needs to be serializable
template <class Inspector> template <class Inspector>
error inspect(Inspector& f, foo& x) { typename Inspector::result_type inspect(Inspector& f, foo& x) {
return f(meta::type_name("foo"), x.a, x.b); return f(meta::type_name("foo"), x.a, x.b);
} }
...@@ -45,7 +45,7 @@ struct foo2 { ...@@ -45,7 +45,7 @@ struct foo2 {
// foo2 also needs to be serializable // foo2 also needs to be serializable
template <class Inspector> template <class Inspector>
error inspect(Inspector& f, foo2& x) { typename Inspector::result_type inspect(Inspector& f, foo2& x) {
return f(meta::type_name("foo2"), x.a, x.b); return f(meta::type_name("foo2"), x.a, x.b);
} }
......
...@@ -41,7 +41,7 @@ public: ...@@ -41,7 +41,7 @@ public:
} }
template <class Inspector> template <class Inspector>
friend error inspect(Inspector& f, foo& x) { friend typename Inspector::result_type inspect(Inspector& f, foo& x) {
return f(meta::type_name("foo"), x.a_, x.b_); return f(meta::type_name("foo"), x.a_, x.b_);
} }
......
...@@ -49,7 +49,7 @@ private: ...@@ -49,7 +49,7 @@ private:
}; };
template <class Inspector> template <class Inspector>
error inspect(Inspector& f, foo& x) { typename Inspector::result_type inspect(Inspector& f, foo& x) {
// store current state into temporaries, then give the inspector references // store current state into temporaries, then give the inspector references
// to temporaries that are written back only when the inspector is saving // to temporaries that are written back only when the inspector is saving
auto a = x.a(); auto a = x.a();
......
...@@ -23,12 +23,6 @@ ...@@ -23,12 +23,6 @@
#include <utility> #include <utility>
#include "caf/fwd.hpp" #include "caf/fwd.hpp"
#include "caf/sec.hpp"
#include "caf/message.hpp"
#include "caf/detail/int_list.hpp"
#include "caf/detail/apply_args.hpp"
#include "caf/detail/pseudo_tuple.hpp"
namespace caf { namespace caf {
......
...@@ -165,7 +165,7 @@ public: ...@@ -165,7 +165,7 @@ public:
actor(actor_control_block*, bool); actor(actor_control_block*, bool);
template <class Inspector> template <class Inspector>
friend error inspect(Inspector& f, actor& x) { friend typename Inspector::result_type inspect(Inspector& f, actor& x) {
return inspect(f, x.ptr_); return inspect(f, x.ptr_);
} }
......
...@@ -110,7 +110,7 @@ public: ...@@ -110,7 +110,7 @@ public:
} }
template <class Inspector> template <class Inspector>
friend error inspect(Inspector& f, actor_addr& x) { friend typename Inspector::result_type inspect(Inspector& f, actor_addr& x) {
return inspect(f, x.ptr_); return inspect(f, x.ptr_);
} }
......
...@@ -201,7 +201,7 @@ inline execution_unit* context_of(void*) { ...@@ -201,7 +201,7 @@ inline execution_unit* context_of(void*) {
} }
template <class Inspector> template <class Inspector>
error inspect(Inspector& f, strong_actor_ptr& x) { typename Inspector::result_type inspect(Inspector& f, strong_actor_ptr& x) {
actor_id aid = 0; actor_id aid = 0;
node_id nid; node_id nid;
if (x) { if (x) {
...@@ -216,7 +216,7 @@ error inspect(Inspector& f, strong_actor_ptr& x) { ...@@ -216,7 +216,7 @@ error inspect(Inspector& f, strong_actor_ptr& x) {
} }
template <class Inspector> template <class Inspector>
error inspect(Inspector& f, weak_actor_ptr& x) { typename Inspector::result_type inspect(Inspector& f, weak_actor_ptr& x) {
// inspect as strong pointer, then write back to weak pointer on save // inspect as strong pointer, then write back to weak pointer on save
auto tmp = x.lock(); auto tmp = x.lock();
auto load = [&]() -> error { x.reset(tmp.get()); return none; }; auto load = [&]() -> error { x.reset(tmp.get()); return none; };
......
...@@ -214,7 +214,7 @@ ...@@ -214,7 +214,7 @@
#ifdef CAF_NO_EXCEPTIONS #ifdef CAF_NO_EXCEPTIONS
# define CAF_RAISE_ERROR(msg) \ # define CAF_RAISE_ERROR(msg) \
do { std::string str = msg; CAF_CRITICAL(str.c_str()); } while (false) do { std::string str = msg; CAF_CRITICAL(str.c_str()); } while (true)
#else // CAF_NO_EXCEPTIONS #else // CAF_NO_EXCEPTIONS
# define CAF_RAISE_ERROR(msg) \ # define CAF_RAISE_ERROR(msg) \
throw std::runtime_error(msg) throw std::runtime_error(msg)
......
...@@ -49,38 +49,12 @@ namespace caf { ...@@ -49,38 +49,12 @@ namespace caf {
template <class Derived> template <class Derived>
class data_processor { class data_processor {
public: public:
data_processor(const data_processor&) = delete; // -- member types -----------------------------------------------------------
data_processor& operator=(const data_processor&) = delete;
data_processor(execution_unit* ctx = nullptr) : context_(ctx) {
// nop
}
virtual ~data_processor() {
// nop
}
/// Begins processing of an object. Saves the type information
/// to the underlying storage when in saving mode, otherwise
/// extracts them and sets both arguments accordingly.
virtual error begin_object(uint16_t& typenr, std::string& name) = 0;
/// Ends processing of an object.
virtual error end_object() = 0;
/// Begins processing of a sequence. Saves the size /// Return type for `operator()`.
/// to the underlying storage when in saving mode, otherwise using result_type = error;
/// sets `num` accordingly.
virtual error begin_sequence(size_t& num) = 0;
/// Ends processing of a sequence.
virtual error end_sequence() = 0;
/// Returns the actor system associated to this data processor.
execution_unit* context() {
return context_;
}
/// List of builtin types for data processors.
using builtin_t = using builtin_t =
detail::type_list< detail::type_list<
int8_t, int8_t,
...@@ -99,7 +73,7 @@ public: ...@@ -99,7 +73,7 @@ public:
std::u32string std::u32string
>; >;
/// Lists all types an implementation has to accept as builtin types. /// List of builtin types for data processors as enum.
enum builtin { enum builtin {
i8_v, i8_v,
u8_v, u8_v,
...@@ -117,6 +91,46 @@ public: ...@@ -117,6 +91,46 @@ public:
string32_v string32_v
}; };
// -- constructors, destructors, and assignment operators --------------------
data_processor(const data_processor&) = delete;
data_processor& operator=(const data_processor&) = delete;
data_processor(execution_unit* ctx = nullptr) : context_(ctx) {
// nop
}
virtual ~data_processor() {
// nop
}
// -- pure virtual functions -------------------------------------------------
/// Begins processing of an object. Saves the type information
/// to the underlying storage when in saving mode, otherwise
/// extracts them and sets both arguments accordingly.
virtual error begin_object(uint16_t& typenr, std::string& name) = 0;
/// Ends processing of an object.
virtual error end_object() = 0;
/// Begins processing of a sequence. Saves the size
/// to the underlying storage when in saving mode, otherwise
/// sets `num` accordingly.
virtual error begin_sequence(size_t& num) = 0;
/// Ends processing of a sequence.
virtual error end_sequence() = 0;
// -- getter -----------------------------------------------------------------
/// Returns the actor system associated to this data processor.
execution_unit* context() {
return context_;
}
// -- apply functions --------------------------------------------------------
/// Applies this processor to an arithmetic type. /// Applies this processor to an arithmetic type.
template <class T> template <class T>
typename std::enable_if<std::is_floating_point<T>::value, error>::type typename std::enable_if<std::is_floating_point<T>::value, error>::type
...@@ -420,6 +434,8 @@ public: ...@@ -420,6 +434,8 @@ public:
return inspect(dref(), x); return inspect(dref(), x);
} }
// -- operator() -------------------------------------------------------------
inline error operator()() { inline error operator()() {
return none; return none;
} }
......
...@@ -32,17 +32,20 @@ namespace detail { ...@@ -32,17 +32,20 @@ namespace detail {
// tuple-like access to an array of void pointers that is // tuple-like access to an array of void pointers that is
// also aware of the semantics of param<T> // also aware of the semantics of param<T>
template <class... T> template <class... Ts>
struct pseudo_tuple { struct pseudo_tuple {
using pointer = void*; using pointer = void*;
using const_pointer = const void*; using const_pointer = const void*;
pointer data[sizeof...(T) > 0 ? sizeof...(T) : 1]; pointer data[sizeof...(Ts) > 0 ? sizeof...(Ts) : 1];
bool shared_access; bool shared_access;
pseudo_tuple(bool is_shared) : shared_access(is_shared) { template <class Tuple>
// nop pseudo_tuple(const Tuple& xs) : data(), shared_access(xs.shared()) {
CAF_ASSERT(sizeof...(Ts) == xs.size());
for (size_t i = 0; i < xs.size(); ++i)
data[i] = const_cast<void*>(xs.get(i));
} }
inline const_pointer at(size_t p) const { inline const_pointer at(size_t p) const {
......
...@@ -45,6 +45,8 @@ namespace detail { ...@@ -45,6 +45,8 @@ namespace detail {
class stringification_inspector { class stringification_inspector {
public: public:
using result_type = error;
using is_saving = std::true_type; using is_saving = std::true_type;
stringification_inspector(std::string& result) : result_(result) { stringification_inspector(std::string& result) : result_(result) {
......
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
#include "caf/type_nr.hpp" #include "caf/type_nr.hpp"
#include "caf/detail/type_list.hpp" #include "caf/detail/type_list.hpp"
#include "caf/detail/pseudo_tuple.hpp"
namespace caf { namespace caf {
namespace detail { namespace detail {
......
...@@ -99,7 +99,8 @@ public: ...@@ -99,7 +99,8 @@ public:
// -- friend functions ------------------------------------------------------- // -- friend functions -------------------------------------------------------
template <class Inspector> template <class Inspector>
friend error inspect(Inspector& f, tuple_vals_impl& x) { friend typename Inspector::result_type inspect(Inspector& f,
tuple_vals_impl& x) {
return apply_args(f, get_indices(x.data_), x.data_); return apply_args(f, get_indices(x.data_), x.data_);
} }
......
/******************************************************************************
* ____ _ _____ *
* / ___| / \ | ___| C++ *
* | | / _ \ | |_ Actor *
* | |___ / ___ \| _| Framework *
* \____/_/ \_|_| *
* *
* Copyright (C) 2011 - 2015 *
* Dominik Charousset <dominik.charousset (at) haw-hamburg.de> *
* *
* Distributed under the terms and conditions of the BSD 3-Clause License or *
* (at your option) under the terms and conditions of the Boost Software *
* License 1.0. See accompanying files LICENSE and LICENSE_ALTERNATIVE. *
* *
* If you did not receive a copy of the license files, see *
* http://opensource.org/licenses/BSD-3-Clause and *
* http://www.boost.org/LICENSE_1_0.txt. *
******************************************************************************/
#ifndef CAF_DETAIL_TUPLE_ZIP_HPP
#define CAF_DETAIL_TUPLE_ZIP_HPP
#include <tuple>
#include "caf/detail/int_list.hpp"
namespace caf {
namespace detail {
template <class F, long... Is, class Tup0, class Tup1>
auto tuple_zip(F& f, detail::int_list<Is...>, Tup0&& tup0, Tup1&& tup1)
-> decltype(std::make_tuple(f(get<Is>(tup0), get<Is>(tup1))...)) {
return std::make_tuple(f(get<Is>(tup0), get<Is>(tup1))...);
}
} // namespace detail
} // namespace caf
#endif // CAF_DETAIL_TUPLE_ZIP_HPP
...@@ -34,7 +34,6 @@ ...@@ -34,7 +34,6 @@
#include "caf/detail/try_match.hpp" #include "caf/detail/try_match.hpp"
#include "caf/detail/apply_args.hpp" #include "caf/detail/apply_args.hpp"
#include "caf/detail/pseudo_tuple.hpp"
namespace caf { namespace caf {
namespace detail { namespace detail {
......
...@@ -142,7 +142,7 @@ private: ...@@ -142,7 +142,7 @@ private:
/// @relates duration /// @relates duration
template <class Inspector> template <class Inspector>
error inspect(Inspector& f, duration& x) { typename Inspector::result_type inspect(Inspector& f, duration& x) {
return f(x.unit, x.count); return f(x.unit, x.count);
} }
......
...@@ -184,7 +184,7 @@ public: ...@@ -184,7 +184,7 @@ public:
// -- friend functions ------------------------------------------------------- // -- friend functions -------------------------------------------------------
template <class Inspector> template <class Inspector>
friend error inspect(Inspector& f, error& x) { friend typename Inspector::result_type inspect(Inspector& f, error& x) {
auto fun = [&](meta::type_name_t x0, uint8_t& x1, atom_value& x2, auto fun = [&](meta::type_name_t x0, uint8_t& x1, atom_value& x2,
meta::omittable_if_empty_t x3, message& x4) -> error{ meta::omittable_if_empty_t x3, message& x4) -> error{
return f(x0, x1, x2, x3, x4); return f(x0, x1, x2, x3, x4);
......
...@@ -51,7 +51,7 @@ enum class exit_reason : uint8_t { ...@@ -51,7 +51,7 @@ enum class exit_reason : uint8_t {
}; };
/// Returns a string representation of given exit reason. /// Returns a string representation of given exit reason.
const char* to_string(exit_reason x); std::string to_string(exit_reason x);
/// @relates exit_reason /// @relates exit_reason
error make_error(exit_reason); error make_error(exit_reason);
......
...@@ -86,7 +86,7 @@ public: ...@@ -86,7 +86,7 @@ public:
} }
template <class Inspector> template <class Inspector>
friend error inspect(Inspector& f, group& x) { friend typename Inspector::result_type inspect(Inspector& f, group& x) {
std::string x_id; std::string x_id;
std::string x_mod; std::string x_mod;
auto ptr = x.get(); auto ptr = x.get();
......
...@@ -50,8 +50,7 @@ inline bool operator==(const index_mapping& x, const index_mapping& y) { ...@@ -50,8 +50,7 @@ inline bool operator==(const index_mapping& x, const index_mapping& y) {
} }
template <class Inspector> template <class Inspector>
auto inspect(Inspector& f, index_mapping& x) typename Inspector::result_type inspect(Inspector& f, index_mapping& x) {
-> decltype(f(meta::type_name("index_mapping"), x.value)) {
return f(meta::type_name("index_mapping"), x.value); return f(meta::type_name("index_mapping"), x.value);
} }
......
...@@ -28,7 +28,7 @@ enum invoke_message_result { ...@@ -28,7 +28,7 @@ enum invoke_message_result {
im_dropped im_dropped
}; };
constexpr const char* to_string(invoke_message_result x) { inline std::string to_string(invoke_message_result x) {
return x == im_success ? "im_success" return x == im_success ? "im_success"
: (x == im_skipped ? "im_skipped" : "im_dropped" ); : (x == im_skipped ? "im_skipped" : "im_dropped" );
} }
......
...@@ -92,7 +92,7 @@ protected: ...@@ -92,7 +92,7 @@ protected:
/// @relates mailbox_element /// @relates mailbox_element
template <class Inspector> template <class Inspector>
void inspect(Inspector& f, mailbox_element& x) { typename Inspector::result_type inspect(Inspector& f, mailbox_element& x) {
return f(meta::type_name("mailbox_element"), x.sender, x.mid, return f(meta::type_name("mailbox_element"), x.sender, x.mid,
meta::omittable_if_empty(), x.stages, x.content()); meta::omittable_if_empty(), x.stages, x.content());
} }
......
...@@ -32,7 +32,6 @@ ...@@ -32,7 +32,6 @@
#include "caf/detail/int_list.hpp" #include "caf/detail/int_list.hpp"
#include "caf/detail/try_match.hpp" #include "caf/detail/try_match.hpp"
#include "caf/detail/type_list.hpp" #include "caf/detail/type_list.hpp"
#include "caf/detail/tuple_zip.hpp"
#include "caf/detail/apply_args.hpp" #include "caf/detail/apply_args.hpp"
#include "caf/detail/type_traits.hpp" #include "caf/detail/type_traits.hpp"
#include "caf/detail/pseudo_tuple.hpp" #include "caf/detail/pseudo_tuple.hpp"
...@@ -169,16 +168,10 @@ public: ...@@ -169,16 +168,10 @@ public:
typename detail::il_indices<decayed_arg_types>::type indices; typename detail::il_indices<decayed_arg_types>::type indices;
lfinvoker<std::is_same<result_type, void>::value, F> fun{fun_}; lfinvoker<std::is_same<result_type, void>::value, F> fun{fun_};
message tmp; message tmp;
intermediate_pseudo_tuple tup{xs.shared()}; auto needs_detaching = is_manipulator && xs.shared();
if (is_manipulator && tup.shared_access) { if (needs_detaching)
tmp = message::copy(xs); tmp = message::copy(xs);
tup.shared_access = false; intermediate_pseudo_tuple tup{needs_detaching ? tmp.content() : xs};
for (size_t i = 0; i < tmp.size(); ++i)
tup[i] = const_cast<void*>(tmp.at(i));
} else {
for (size_t i = 0; i < xs.size(); ++i)
tup[i] = const_cast<void*>(xs.get(i));
}
auto fun_res = apply_args(fun, indices, tup); auto fun_res = apply_args(fun, indices, tup);
return f.visit(fun_res) ? match_case::match : match_case::skip; return f.visit(fun_res) ? match_case::match : match_case::skip;
} }
......
...@@ -301,6 +301,16 @@ public: ...@@ -301,6 +301,16 @@ public:
return size() == (sizeof...(Ts) + 1) && match_elements_impl(p0, list); return size() == (sizeof...(Ts) + 1) && match_elements_impl(p0, list);
} }
/// @cond PRIVATE
/// @pre `! empty()`
type_erased_tuple& content() {
CAF_ASSERT(vals_);
return *vals_;
}
/// @endcond
private: private:
template <size_t P> template <size_t P>
static bool match_elements_impl(std::integral_constant<size_t, P>, static bool match_elements_impl(std::integral_constant<size_t, P>,
......
...@@ -136,7 +136,7 @@ public: ...@@ -136,7 +136,7 @@ public:
} }
template <class Inspector> template <class Inspector>
friend error inspect(Inspector& f, message_id& x) { friend typename Inspector::result_type inspect(Inspector& f, message_id& x) {
return f(meta::type_name("message_id"), x.value_); return f(meta::type_name("message_id"), x.value_);
} }
......
...@@ -126,7 +126,8 @@ public: ...@@ -126,7 +126,8 @@ public:
explicit node_id(intrusive_ptr<data> dataptr); explicit node_id(intrusive_ptr<data> dataptr);
template <class Inspector> template <class Inspector>
friend detail::enable_if_t<Inspector::is_saving::value, error> friend detail::enable_if_t<Inspector::is_saving::value,
typename Inspector::result_type>
inspect(Inspector& f, node_id& x) { inspect(Inspector& f, node_id& x) {
data tmp; data tmp;
data* ptr = x ? x.data_.get() : &tmp; data* ptr = x ? x.data_.get() : &tmp;
...@@ -135,20 +136,19 @@ public: ...@@ -135,20 +136,19 @@ public:
} }
template <class Inspector> template <class Inspector>
friend detail::enable_if_t<Inspector::is_loading::value, error> friend detail::enable_if_t<Inspector::is_loading::value,
typename Inspector::result_type>
inspect(Inspector& f, node_id& x) { inspect(Inspector& f, node_id& x) {
data tmp; data tmp;
auto err = f(meta::type_name("node_id"), tmp.pid_, auto result = f(meta::type_name("node_id"), tmp.pid_,
meta::hex_formatted(), tmp.host_); meta::hex_formatted(), tmp.host_);
if (! err) { if (! tmp.valid())
if (! tmp.valid()) x.data_.reset();
x.data_.reset(); else if (! x || ! x.data_->unique())
else if (! x || ! x.data_->unique()) x.data_.reset(new data(tmp));
x.data_.reset(new data(tmp)); else
else *x.data_ = tmp;
*x.data_ = tmp; return result;
}
return err;
} }
/// @endcond /// @endcond
......
...@@ -92,7 +92,7 @@ enum class sec : uint8_t { ...@@ -92,7 +92,7 @@ enum class sec : uint8_t {
}; };
/// @relates sec /// @relates sec
const char* to_string(sec); std::string to_string(sec);
/// @relates sec /// @relates sec
error make_error(sec); error make_error(sec);
......
...@@ -123,8 +123,8 @@ protected: ...@@ -123,8 +123,8 @@ protected:
error apply_builtin(builtin type, void* val) override { error apply_builtin(builtin type, void* val) override {
CAF_ASSERT(val != nullptr); CAF_ASSERT(val != nullptr);
switch (type) { switch (type) {
case i8_v: default: // i8_v or u8_v
case u8_v: CAF_ASSERT(type == i8_v || type == u8_v);
return apply_raw(sizeof(uint8_t), val); return apply_raw(sizeof(uint8_t), val);
case i16_v: case i16_v:
case u16_v: case u16_v:
...@@ -201,7 +201,7 @@ private: ...@@ -201,7 +201,7 @@ private:
template <class T> template <class T>
error apply_float(T& x) { error apply_float(T& x) {
typename detail::ieee_754_trait<T>::packed_type tmp; typename detail::ieee_754_trait<T>::packed_type tmp = 0;
auto e = apply_int(tmp); auto e = apply_int(tmp);
if (e) if (e)
return e; return e;
......
...@@ -124,8 +124,8 @@ protected: ...@@ -124,8 +124,8 @@ protected:
error apply_builtin(builtin type, void* val) override { error apply_builtin(builtin type, void* val) override {
CAF_ASSERT(val != nullptr); CAF_ASSERT(val != nullptr);
switch (type) { switch (type) {
case i8_v: default: // i8_v or u8_v
case u8_v: CAF_ASSERT(type == i8_v || type == u8_v);
return apply_raw(sizeof(uint8_t), val); return apply_raw(sizeof(uint8_t), val);
case i16_v: case i16_v:
case u16_v: case u16_v:
......
...@@ -71,7 +71,7 @@ private: ...@@ -71,7 +71,7 @@ private:
/// @relates exit_msg /// @relates exit_msg
template <class Inspector> template <class Inspector>
error inspect(Inspector& f, exit_msg& x) { typename Inspector::result_type inspect(Inspector& f, exit_msg& x) {
return f(meta::type_name("exit_msg"), x.source, x.reason); return f(meta::type_name("exit_msg"), x.source, x.reason);
} }
...@@ -108,7 +108,7 @@ private: ...@@ -108,7 +108,7 @@ private:
/// @relates down_msg /// @relates down_msg
template <class Inspector> template <class Inspector>
error inspect(Inspector& f, down_msg& x) { typename Inspector::result_type inspect(Inspector& f, down_msg& x) {
return f(meta::type_name("down_msg"), x.source, x.reason); return f(meta::type_name("down_msg"), x.source, x.reason);
} }
...@@ -120,7 +120,7 @@ struct group_down_msg { ...@@ -120,7 +120,7 @@ struct group_down_msg {
/// @relates group_down_msg /// @relates group_down_msg
template <class Inspector> template <class Inspector>
error inspect(Inspector& f, group_down_msg& x) { typename Inspector::result_type inspect(Inspector& f, group_down_msg& x) {
return f(meta::type_name("group_down_msg"), x.source); return f(meta::type_name("group_down_msg"), x.source);
} }
...@@ -133,7 +133,7 @@ struct timeout_msg { ...@@ -133,7 +133,7 @@ struct timeout_msg {
/// @relates timeout_msg /// @relates timeout_msg
template <class Inspector> template <class Inspector>
error inspect(Inspector& f, timeout_msg& x) { typename Inspector::result_type inspect(Inspector& f, timeout_msg& x) {
return f(meta::type_name("timeout_msg"), x.timeout_id); return f(meta::type_name("timeout_msg"), x.timeout_id);
} }
......
...@@ -174,9 +174,7 @@ private: ...@@ -174,9 +174,7 @@ private:
detail::type_list<Ts...> tk) { detail::type_list<Ts...> tk) {
if (! match_elements<Ts...>()) if (! match_elements<Ts...>())
return none; return none;
detail::pseudo_tuple<typename std::decay<Ts>::type...> xs{shared()}; detail::pseudo_tuple<typename std::decay<Ts>::type...> xs{*this};
for (size_t i = 0; i < size(); ++i)
xs[i] = const_cast<void*>(get(i)); // pseud_tuple figures out const-ness
return detail::apply_args(fun, detail::get_indices(tk), xs); return detail::apply_args(fun, detail::get_indices(tk), xs);
} }
...@@ -185,9 +183,7 @@ private: ...@@ -185,9 +183,7 @@ private:
detail::type_list<Ts...> tk) { detail::type_list<Ts...> tk) {
if (! match_elements<Ts...>()) if (! match_elements<Ts...>())
return none; return none;
detail::pseudo_tuple<typename std::decay<Ts>::type...> xs{shared()}; detail::pseudo_tuple<typename std::decay<Ts>::type...> xs{*this};
for (size_t i = 0; i < size(); ++i)
xs[i] = const_cast<void*>(get(i)); // pseud_tuple figures out const-ness
detail::apply_args(fun, detail::get_indices(tk), xs); detail::apply_args(fun, detail::get_indices(tk), xs);
return unit; return unit;
} }
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include <functional> #include <functional>
#include "caf/fwd.hpp" #include "caf/fwd.hpp"
#include "caf/error.hpp"
#include "caf/type_nr.hpp" #include "caf/type_nr.hpp"
namespace caf { namespace caf {
...@@ -97,16 +98,12 @@ public: ...@@ -97,16 +98,12 @@ public:
}; };
/// @relates type_erased_value_impl /// @relates type_erased_value_impl
template <class Inspector> inline error inspect(serializer& f, type_erased_value& x) {
typename std::enable_if<Inspector::is_saving::value, error>::type
inspect(Inspector& f, type_erased_value& x) {
return x.save(f); return x.save(f);
} }
/// @relates type_erased_value_impl /// @relates type_erased_value_impl
template <class Inspector> inline error inspect(deserializer& f, type_erased_value& x) {
typename std::enable_if<Inspector::is_loading::value, error>::type
inspect(Inspector& f, type_erased_value& x) {
return x.load(f); return x.load(f);
} }
......
...@@ -242,7 +242,7 @@ class typed_actor : detail::comparable<typed_actor<Sigs...>>, ...@@ -242,7 +242,7 @@ class typed_actor : detail::comparable<typed_actor<Sigs...>>,
} }
template <class Inspector> template <class Inspector>
friend error inspect(Inspector& f, typed_actor& x) { friend typename Inspector::result_type inspect(Inspector& f, typed_actor& x) {
return f(x.ptr_); return f(x.ptr_);
} }
......
...@@ -40,7 +40,7 @@ const char* exit_reason_strings[] = { ...@@ -40,7 +40,7 @@ const char* exit_reason_strings[] = {
} // namespace <anonymous> } // namespace <anonymous>
const char* to_string(exit_reason x) { std::string to_string(exit_reason x) {
auto index = static_cast<size_t>(x); auto index = static_cast<size_t>(x);
if (index > static_cast<size_t>(exit_reason::unreachable)) if (index > static_cast<size_t>(exit_reason::unreachable))
return "<unknown>"; return "<unknown>";
......
...@@ -57,7 +57,7 @@ const char* sec_strings[] = { ...@@ -57,7 +57,7 @@ const char* sec_strings[] = {
} // namespace <anonymous> } // namespace <anonymous>
const char* to_string(sec x) { std::string to_string(sec x) {
auto index = static_cast<size_t>(x); auto index = static_cast<size_t>(x);
if (index > static_cast<size_t>(sec::bad_function_call)) if (index > static_cast<size_t>(sec::bad_function_call))
return "<unknown>"; return "<unknown>";
......
...@@ -121,7 +121,8 @@ public: ...@@ -121,7 +121,8 @@ public:
} }
template <class Inspector> template <class Inspector>
friend error inspect(Inspector& f, counting_string& x) { friend typename Inspector::result_type inspect(Inspector& f,
counting_string& x) {
return f(x.str_); return f(x.str_);
} }
......
...@@ -171,7 +171,7 @@ struct s1 { ...@@ -171,7 +171,7 @@ struct s1 {
}; };
template <class Inspector> template <class Inspector>
error inspect(Inspector& f, s1& x) { typename Inspector::result_type inspect(Inspector& f, s1& x) {
return f(x.value); return f(x.value);
} }
...@@ -180,7 +180,7 @@ struct s2 { ...@@ -180,7 +180,7 @@ struct s2 {
}; };
template <class Inspector> template <class Inspector>
error inspect(Inspector& f, s2& x) { typename Inspector::result_type inspect(Inspector& f, s2& x) {
return f(x.value); return f(x.value);
} }
...@@ -192,7 +192,7 @@ struct s3 { ...@@ -192,7 +192,7 @@ struct s3 {
}; };
template <class Inspector> template <class Inspector>
error inspect(Inspector& f, s3& x) { typename Inspector::result_type inspect(Inspector& f, s3& x) {
return f(x.value); return f(x.value);
} }
......
...@@ -80,7 +80,7 @@ struct raw_struct { ...@@ -80,7 +80,7 @@ struct raw_struct {
}; };
template <class Inspector> template <class Inspector>
error inspect(Inspector& f, raw_struct& x) { typename Inspector::result_type inspect(Inspector& f, raw_struct& x) {
return f(x.str); return f(x.str);
} }
...@@ -109,7 +109,7 @@ struct test_array { ...@@ -109,7 +109,7 @@ struct test_array {
}; };
template <class Inspector> template <class Inspector>
error inspect(Inspector& f, test_array& x) { typename Inspector::result_type inspect(Inspector& f, test_array& x) {
return f(x.value, x.value2); return f(x.value, x.value2);
} }
...@@ -125,7 +125,7 @@ struct test_empty_non_pod { ...@@ -125,7 +125,7 @@ struct test_empty_non_pod {
}; };
template <class Inspector> template <class Inspector>
error inspect(Inspector&, test_empty_non_pod&) { typename Inspector::result_type inspect(Inspector&, test_empty_non_pod&) {
return none; return none;
} }
......
...@@ -85,7 +85,7 @@ struct my_request { ...@@ -85,7 +85,7 @@ struct my_request {
}; };
template <class Inspector> template <class Inspector>
error inspect(Inspector& f, my_request& x) { typename Inspector::result_type inspect(Inspector& f, my_request& x) {
return f(x.a, x.b); return f(x.a, x.b);
} }
......
...@@ -56,7 +56,8 @@ public: ...@@ -56,7 +56,8 @@ public:
} }
template <class Inspector> template <class Inspector>
friend error inspect(Inspector& f, accept_handle& x) { friend typename Inspector::result_type inspect(Inspector& f,
accept_handle& x) {
return f(meta::type_name("accept_handle"), x.id_); return f(meta::type_name("accept_handle"), x.id_);
} }
......
...@@ -40,7 +40,7 @@ enum connection_state { ...@@ -40,7 +40,7 @@ enum connection_state {
}; };
/// @relates connection_state /// @relates connection_state
constexpr const char* to_string(connection_state x) { inline std::string to_string(connection_state x) {
return x == await_header ? "await_header" return x == await_header ? "await_header"
: (x == await_payload ? "await_payload" : (x == await_payload ? "await_payload"
: "close_connection"); : "close_connection");
......
...@@ -81,7 +81,7 @@ struct header { ...@@ -81,7 +81,7 @@ struct header {
/// @relates header /// @relates header
template <class Inspector> template <class Inspector>
error inspect(Inspector& f, header& hdr) { typename Inspector::result_type inspect(Inspector& f, header& hdr) {
uint8_t pad = 0; uint8_t pad = 0;
return f(meta::type_name("header"), return f(meta::type_name("header"),
hdr.operation, hdr.operation,
......
...@@ -38,8 +38,8 @@ public: ...@@ -38,8 +38,8 @@ public:
: Base(ptr), : Base(ptr),
hdl_(x), hdl_(x),
value_(strong_actor_ptr{}, message_id::make(), value_(strong_actor_ptr{}, message_id::make(),
mailbox_element::forwarding_stack{}, SysMsgType{}) { mailbox_element::forwarding_stack{}, SysMsgType{x, {}}) {
set_hdl(msg(), x); // nop
} }
Handle hdl() const { Handle hdl() const {
...@@ -67,14 +67,6 @@ protected: ...@@ -67,14 +67,6 @@ protected:
return value_.template get_mutable_as<SysMsgType>(0); return value_.template get_mutable_as<SysMsgType>(0);
} }
static void set_hdl(new_connection_msg& lhs, Handle& hdl) {
lhs.source = hdl;
}
static void set_hdl(new_data_msg& lhs, Handle& hdl) {
lhs.handle = hdl;
}
Handle hdl_; Handle hdl_;
mailbox_element_vals<SysMsgType> value_; mailbox_element_vals<SysMsgType> value_;
}; };
......
...@@ -57,7 +57,8 @@ public: ...@@ -57,7 +57,8 @@ public:
} }
template <class Inspector> template <class Inspector>
friend error inspect(Inspector& f, connection_handle& x) { friend typename Inspector::result_type inspect(Inspector& f,
connection_handle& x) {
return f(meta::type_name("connection_handle"), x.id_); return f(meta::type_name("connection_handle"), x.id_);
} }
......
...@@ -31,7 +31,7 @@ enum class operation { ...@@ -31,7 +31,7 @@ enum class operation {
propagate_error propagate_error
}; };
constexpr const char* to_string(operation op) { inline std::string to_string(operation op) {
return op == operation::read ? "read" return op == operation::read ? "read"
: (op == operation::write ? "write" : (op == operation::write ? "write"
: "propagate_error"); : "propagate_error");
......
...@@ -34,7 +34,7 @@ enum class protocol : uint32_t { ...@@ -34,7 +34,7 @@ enum class protocol : uint32_t {
}; };
/// @relates protocol /// @relates protocol
constexpr const char* to_string(protocol value) { inline std::string to_string(protocol value) {
return value == protocol::ethernet ? "ethernet" return value == protocol::ethernet ? "ethernet"
: (value == protocol::ipv4 ? "ipv4" : (value == protocol::ipv4 ? "ipv4"
: "ipv6"); : "ipv6");
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#ifndef CAF_IO_RECEIVE_POLICY_HPP #ifndef CAF_IO_RECEIVE_POLICY_HPP
#define CAF_IO_RECEIVE_POLICY_HPP #define CAF_IO_RECEIVE_POLICY_HPP
#include <string>
#include <cstddef> #include <cstddef>
#include <utility> #include <utility>
...@@ -34,7 +35,7 @@ enum class receive_policy_flag { ...@@ -34,7 +35,7 @@ enum class receive_policy_flag {
exactly exactly
}; };
constexpr const char* to_string(receive_policy_flag x) { inline std::string to_string(receive_policy_flag x) {
return x == receive_policy_flag::at_least return x == receive_policy_flag::at_least
? "at_least" ? "at_least"
: (x == receive_policy_flag::at_most ? "at_most" : "exactly"); : (x == receive_policy_flag::at_most ? "at_most" : "exactly");
......
...@@ -43,7 +43,7 @@ struct new_connection_msg { ...@@ -43,7 +43,7 @@ struct new_connection_msg {
}; };
template <class Inspector> template <class Inspector>
error inspect(Inspector& f, new_connection_msg& x) { typename Inspector::result_type inspect(Inspector& f, new_connection_msg& x) {
return f(meta::type_name("new_connection_msg"), x.source, x.handle); return f(meta::type_name("new_connection_msg"), x.source, x.handle);
} }
...@@ -69,7 +69,7 @@ struct new_data_msg { ...@@ -69,7 +69,7 @@ struct new_data_msg {
/// @relates new_data_msg /// @relates new_data_msg
template <class Inspector> template <class Inspector>
error inspect(Inspector& f, new_data_msg& x) { typename Inspector::result_type inspect(Inspector& f, new_data_msg& x) {
return f(meta::type_name("new_data_msg"), x.handle, x.buf); return f(meta::type_name("new_data_msg"), x.handle, x.buf);
} }
...@@ -95,7 +95,7 @@ struct data_transferred_msg { ...@@ -95,7 +95,7 @@ struct data_transferred_msg {
/// @relates data_transferred_msg /// @relates data_transferred_msg
template <class Inspector> template <class Inspector>
error inspect(Inspector& f, data_transferred_msg& x) { typename Inspector::result_type inspect(Inspector& f, data_transferred_msg& x) {
return f(meta::type_name("data_transferred_msg"), return f(meta::type_name("data_transferred_msg"),
x.handle, x.written, x.remaining); x.handle, x.written, x.remaining);
} }
...@@ -123,7 +123,7 @@ struct connection_closed_msg { ...@@ -123,7 +123,7 @@ struct connection_closed_msg {
/// @relates connection_closed_msg /// @relates connection_closed_msg
template <class Inspector> template <class Inspector>
error inspect(Inspector& f, connection_closed_msg& x) { typename Inspector::result_type inspect(Inspector& f, connection_closed_msg& x) {
return f(meta::type_name("connection_closed_msg"), x.handle); return f(meta::type_name("connection_closed_msg"), x.handle);
} }
...@@ -147,7 +147,7 @@ struct acceptor_closed_msg { ...@@ -147,7 +147,7 @@ struct acceptor_closed_msg {
/// @relates connection_closed_msg /// @relates connection_closed_msg
template <class Inspector> template <class Inspector>
error inspect(Inspector& f, acceptor_closed_msg& x) { typename Inspector::result_type inspect(Inspector& f, acceptor_closed_msg& x) {
return f(meta::type_name("acceptor_closed_msg"), x.handle); return f(meta::type_name("acceptor_closed_msg"), x.handle);
} }
......
...@@ -40,7 +40,7 @@ struct ping { ...@@ -40,7 +40,7 @@ struct ping {
}; };
template <class Inspector> template <class Inspector>
error inspect(Inspector& f, ping& x) { typename Inspector::result_type inspect(Inspector& f, ping& x) {
return f(meta::type_name("ping"), x.value); return f(meta::type_name("ping"), x.value);
} }
...@@ -53,7 +53,7 @@ struct pong { ...@@ -53,7 +53,7 @@ struct pong {
}; };
template <class Inspector> template <class Inspector>
error inspect(Inspector& f, pong& x) { typename Inspector::result_type inspect(Inspector& f, pong& x) {
return f(meta::type_name("pong"), x.value); return f(meta::type_name("pong"), x.value);
} }
......
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