Commit 4a9ea16f authored by Dominik Charousset's avatar Dominik Charousset

Coding style nitpicks

parent 5bbd5b8a
...@@ -66,14 +66,14 @@ class abstract_event_based_actor : public ...@@ -66,14 +66,14 @@ class abstract_event_based_actor : public
!std::is_same<keep_behavior_t, typename std::decay<T>::type>::value, !std::is_same<keep_behavior_t, typename std::decay<T>::type>::value,
void void
>::type >::type
become(T&& arg, Ts&&... args) { become(T&& x, Ts&&... xs) {
behavior_type bhvr{std::forward<T>(arg), std::forward<Ts>(args)...}; behavior_type bhvr{std::forward<T>(x), std::forward<Ts>(xs)...};
this->do_become(std::move(unbox(bhvr)), true); this->do_become(std::move(unbox(bhvr)), true);
} }
template <class... Ts> template <class... Ts>
void become(const keep_behavior_t&, Ts&&... args) { void become(const keep_behavior_t&, Ts&&... xs) {
behavior_type bhvr{std::forward<Ts>(args)...}; behavior_type bhvr{std::forward<Ts>(xs)...};
this->do_become(std::move(unbox(bhvr)), false); this->do_become(std::move(unbox(bhvr)), false);
} }
...@@ -83,12 +83,12 @@ class abstract_event_based_actor : public ...@@ -83,12 +83,12 @@ class abstract_event_based_actor : public
private: private:
template <class... Ts> template <class... Ts>
static behavior& unbox(typed_behavior<Ts...>& arg) { static behavior& unbox(typed_behavior<Ts...>& x) {
return arg.unbox(); return x.unbox();
} }
static inline behavior& unbox(behavior& bhvr) { static inline behavior& unbox(behavior& x) {
return bhvr; return x;
} }
}; };
......
...@@ -88,56 +88,55 @@ const uniform_type_info* announce(const std::type_info& tinfo, ...@@ -88,56 +88,55 @@ const uniform_type_info* announce(const std::type_info& tinfo,
// deals with member pointer // deals with member pointer
/** /**
* Creates meta information for a non-trivial member `C`, whereas * Creates meta information for a non-trivial `Member`,
* `args` are the "sub-members" of `c_ptr`. * whereas `xs` are the "sub-members" of `Member`.
* @see {@link announce_4.cpp announce example 4} * @see {@link announce_4.cpp announce example 4}
*/ */
template <class C, class Parent, class... Ts> template <class Member, class Parent, class... Ts>
std::pair<C Parent::*, detail::abstract_uniform_type_info<C>*> std::pair<Member Parent::*, detail::abstract_uniform_type_info<Member>*>
compound_member(C Parent::*c_ptr, const Ts&... args) { compound_member(Member Parent::*memptr, const Ts&... xs) {
return {c_ptr, new detail::default_uniform_type_info<C>("???", args...)}; return {memptr, new detail::default_uniform_type_info<Member>("???", xs...)};
} }
// deals with getter returning a mutable reference // deals with getter returning a mutable reference
/** /**
* Creates meta information for a non-trivial member accessed * Creates meta information for a non-trivial `Member` accessed
* via a getter returning a mutable reference, whereas * via the getter member function `getter` returning a mutable reference,
* `args` are the "sub-members" of `c_ptr`. * whereas `xs` are the "sub-members" of `Member`.
* @see {@link announce_4.cpp announce example 4} * @see {@link announce_4.cpp announce example 4}
*/ */
template <class C, class Parent, class... Ts> template <class Member, class Parent, class... Ts>
std::pair<C& (Parent::*)(), detail::abstract_uniform_type_info<C>*> std::pair<Member& (Parent::*)(), detail::abstract_uniform_type_info<Member>*>
compound_member(C& (Parent::*getter)(), const Ts&... args) { compound_member(Member& (Parent::*getter)(), const Ts&... xs) {
return {getter, new detail::default_uniform_type_info<C>("???", args...)}; return {getter, new detail::default_uniform_type_info<Member>("???", xs...)};
} }
// deals with getter/setter pair // deals with getter/setter pair
/** /**
* Creates meta information for a non-trivial member accessed * Creates meta information for a non-trivial `Member` accessed
* via a pair of getter and setter member function pointers, whereas * via the pair of getter and setter member function pointers `gspair`,
* `args` are the "sub-members" of `c_ptr`. * whereas `xs` are the "sub-members" of `Member`.
* @see {@link announce_4.cpp announce example 4} * @see {@link announce_4.cpp announce example 4}
*/ */
template <class Parent, class GRes, class SRes, class SArg, class... Ts> template <class Parent, class GRes, class SRes, class SArg, class... Ts>
std::pair<std::pair<GRes (Parent::*)() const, SRes (Parent::*)(SArg)>, std::pair<std::pair<GRes (Parent::*)() const, SRes (Parent::*)(SArg)>,
detail::abstract_uniform_type_info< detail::abstract_uniform_type_info<typename std::decay<GRes>::type>*>
typename std::decay<GRes>::type>*>
compound_member(const std::pair<GRes (Parent::*)() const, compound_member(const std::pair<GRes (Parent::*)() const,
SRes (Parent::*)(SArg)>& gspair, SRes (Parent::*)(SArg)>& gspair,
const Ts&... args) { const Ts&... xs) {
using mtype = typename std::decay<GRes>::type; using mtype = typename std::decay<GRes>::type;
return {gspair, new detail::default_uniform_type_info<mtype>("???", args...)}; return {gspair, new detail::default_uniform_type_info<mtype>("???", xs...)};
} }
/** /**
* Adds a new type mapping for `C` to the type system * Adds a new type mapping for `T` to the type system using `tname`
* using `tname` as its uniform name. * as its uniform name and the list of member pointers `xs`.
* @warning `announce` is **not** thead-safe! * @warning `announce` is **not** thead-safe!
*/ */
template <class C, class... Ts> template <class T, class... Ts>
inline const uniform_type_info* announce(std::string tname, const Ts&... args) { inline const uniform_type_info* announce(std::string tname, const Ts&... xs) {
auto ptr = new detail::default_uniform_type_info<C>(std::move(tname), args...); auto ptr = new detail::default_uniform_type_info<T>(std::move(tname), xs...);
return announce(typeid(C), uniform_type_info_ptr{ptr}); return announce(typeid(T), uniform_type_info_ptr{ptr});
} }
/** /**
......
...@@ -111,12 +111,10 @@ class behavior { ...@@ -111,12 +111,10 @@ class behavior {
} }
/** /**
* Returns a value if `arg` was matched by one of the * Runs this handler and returns its (optional) result.
* handler of this behavior, returns `nothing` otherwise.
*/ */
template <class T> inline optional<message> operator()(message& arg) {
optional<message> operator()(T&& arg) { return (m_impl) ? m_impl->invoke(arg) : none;
return (m_impl) ? m_impl->invoke(std::forward<T>(arg)) : none;
} }
/** /**
......
...@@ -65,10 +65,10 @@ class blocking_actor ...@@ -65,10 +65,10 @@ class blocking_actor
std::function<bool()> m_stmt; std::function<bool()> m_stmt;
template <class... Ts> template <class... Ts>
void operator()(Ts&&... args) { void operator()(Ts&&... xs) {
static_assert(sizeof...(Ts) > 0, static_assert(sizeof...(Ts) > 0,
"operator() requires at least one argument"); "operator() requires at least one argument");
behavior bhvr{std::forward<Ts>(args)...}; behavior bhvr{std::forward<Ts>(xs)...};
while (m_stmt()) m_dq(bhvr); while (m_stmt()) m_dq(bhvr);
} }
}; };
...@@ -80,8 +80,8 @@ class blocking_actor ...@@ -80,8 +80,8 @@ class blocking_actor
T end; T end;
template <class... Ts> template <class... Ts>
void operator()(Ts&&... args) { void operator()(Ts&&... xs) {
behavior bhvr{std::forward<Ts>(args)...}; behavior bhvr{std::forward<Ts>(xs)...};
for (; begin != end; ++begin) m_dq(bhvr); for (; begin != end; ++begin) m_dq(bhvr);
} }
}; };
...@@ -107,9 +107,9 @@ class blocking_actor ...@@ -107,9 +107,9 @@ class blocking_actor
* matched by given behavior. * matched by given behavior.
*/ */
template <class... Ts> template <class... Ts>
void receive(Ts&&... args) { void receive(Ts&&... xs) {
static_assert(sizeof...(Ts), "at least one argument required"); static_assert(sizeof...(Ts), "at least one argument required");
behavior bhvr{std::forward<Ts>(args)...}; behavior bhvr{std::forward<Ts>(xs)...};
dequeue(bhvr); dequeue(bhvr);
} }
...@@ -118,8 +118,8 @@ class blocking_actor ...@@ -118,8 +118,8 @@ class blocking_actor
* not cause a temporary behavior object per iteration. * not cause a temporary behavior object per iteration.
*/ */
template <class... Ts> template <class... Ts>
void receive_loop(Ts&&... args) { void receive_loop(Ts&&... xs) {
behavior bhvr{std::forward<Ts>(args)...}; behavior bhvr{std::forward<Ts>(xs)...};
for (;;) dequeue(bhvr); for (;;) dequeue(bhvr);
} }
...@@ -182,8 +182,8 @@ class blocking_actor ...@@ -182,8 +182,8 @@ class blocking_actor
* ~~~ * ~~~
*/ */
template <class... Ts> template <class... Ts>
do_receive_helper do_receive(Ts&&... args) { do_receive_helper do_receive(Ts&&... xs) {
return {make_dequeue_callback(), behavior{std::forward<Ts>(args)...}}; return {make_dequeue_callback(), behavior{std::forward<Ts>(xs)...}};
} }
/** /**
......
...@@ -475,9 +475,9 @@ class default_uniform_type_info : public detail::abstract_uniform_type_info<T> { ...@@ -475,9 +475,9 @@ class default_uniform_type_info : public detail::abstract_uniform_type_info<T> {
using super = detail::abstract_uniform_type_info<T>; using super = detail::abstract_uniform_type_info<T>;
template <class... Ts> template <class... Ts>
default_uniform_type_info(std::string tname, Ts&&... args) default_uniform_type_info(std::string tname, Ts&&... xs)
: super(std::move(tname)) { : super(std::move(tname)) {
push_back(std::forward<Ts>(args)...); push_back(std::forward<Ts>(xs)...);
} }
default_uniform_type_info(std::string tname) : super(std::move(tname)) { default_uniform_type_info(std::string tname) : super(std::move(tname)) {
...@@ -525,46 +525,45 @@ class default_uniform_type_info : public detail::abstract_uniform_type_info<T> { ...@@ -525,46 +525,45 @@ class default_uniform_type_info : public detail::abstract_uniform_type_info<T> {
} }
template <class R, class C, class... Ts> template <class R, class C, class... Ts>
void push_back(R C::*memptr, Ts&&... args) { void push_back(R C::*memptr, Ts&&... xs) {
m_members.push_back(new_member_tinfo(memptr)); m_members.push_back(new_member_tinfo(memptr));
push_back(std::forward<Ts>(args)...); push_back(std::forward<Ts>(xs)...);
} }
// pr.first = member pointer // pr.first = member pointer
// pr.second = meta object to handle pr.first // pr.second = meta object to handle pr.first
template <class R, class C, class... Ts> template <class R, class C, class... Ts>
void push_back( void push_back(const std::pair<R C::*,
const std::pair<R C::*, detail::abstract_uniform_type_info<R>*>& pr, detail::abstract_uniform_type_info<R>*>& pr,
Ts&&... args) { Ts&&... xs) {
m_members.push_back( m_members.push_back(new_member_tinfo(pr.first,
new_member_tinfo(pr.first, uniform_type_info_ptr(pr.second))); uniform_type_info_ptr(pr.second)));
push_back(std::forward<Ts>(args)...); push_back(std::forward<Ts>(xs)...);
} }
// pr.first = getter / setter pair // pr.first = const-qualified getter
// pr.second = meta object to handle pr.first // pr.second = setter with one argument
template <class GR, typename SR, typename ST, typename C, class... Ts> template <class GR, typename SR, typename ST, typename C, class... Ts>
void push_back(const std::pair<GR (C::*)() const, // const-qualified getter void push_back(const std::pair<GR (C::*)() const,
SR (C::*)(ST) // setter with one argument SR (C::*)(ST)>& pr,
>& pr, Ts&&... xs) {
Ts&&... args) {
m_members.push_back(new_member_tinfo(pr.first, pr.second)); m_members.push_back(new_member_tinfo(pr.first, pr.second));
push_back(std::forward<Ts>(args)...); push_back(std::forward<Ts>(xs)...);
} }
// pr.first = getter / setter pair // pr.first = pair of const-qualified getter and setter with one argument
// pr.second = meta object to handle pr.first // pr.second = uniform type info pointer
template <class GR, typename SR, typename ST, typename C, class... Ts> template <class GR, typename SR, typename ST, typename C, class... Ts>
void push_back( void push_back(const std::pair<
const std::pair<std::pair<GR (C::*)() const, // const-qualified getter std::pair<GR (C::*)() const,
SR (C::*)(ST) // setter with one argument SR (C::*)(ST)>,
>, detail::abstract_uniform_type_info<
detail::abstract_uniform_type_info< typename std::decay<GR>::type>*
typename std::decay<GR>::type>*>& pr, >& pr,
Ts&&... args) { Ts&&... xs) {
m_members.push_back(new_member_tinfo(pr.first.first, pr.first.second, m_members.push_back(new_member_tinfo(pr.first.first, pr.first.second,
uniform_type_info_ptr(pr.second))); uniform_type_info_ptr(pr.second)));
push_back(std::forward<Ts>(args)...); push_back(std::forward<Ts>(xs)...);
} }
std::vector<uniform_type_info_ptr> m_members; std::vector<uniform_type_info_ptr> m_members;
......
...@@ -88,14 +88,14 @@ class memory { ...@@ -88,14 +88,14 @@ class memory {
// Allocates storage, initializes a new object, and returns the new instance. // Allocates storage, initializes a new object, and returns the new instance.
template <class T, class... Ts> template <class T, class... Ts>
static T* create(Ts&&... args) { static T* create(Ts&&... xs) {
using embedded_t = using embedded_t =
typename std::conditional< typename std::conditional<
T::memory_cache_flag == provides_embedding, T::memory_cache_flag == provides_embedding,
rc_storage<T>, rc_storage<T>,
T T
>::type; >::type;
return unbox_rc_storage(new embedded_t(std::forward<Ts>(args)...)); return unbox_rc_storage(new embedded_t(std::forward<Ts>(xs)...));
} }
static inline memory_cache* get_cache_map_entry(const std::type_info*) { static inline memory_cache* get_cache_map_entry(const std::type_info*) {
......
...@@ -97,9 +97,9 @@ class message_case_pair_builder : public message_case_builder { ...@@ -97,9 +97,9 @@ class message_case_pair_builder : public message_case_builder {
struct tuple_maker { struct tuple_maker {
template <class... Ts> template <class... Ts>
inline auto operator()(Ts&&... args) inline auto operator()(Ts&&... xs)
-> decltype(std::make_tuple(std::forward<Ts>(args)...)) { -> decltype(std::make_tuple(std::forward<Ts>(xs)...)) {
return std::make_tuple(std::forward<Ts>(args)...); return std::make_tuple(std::forward<Ts>(xs)...);
} }
}; };
......
...@@ -53,7 +53,7 @@ class singleton_mixin : public Base { ...@@ -53,7 +53,7 @@ class singleton_mixin : public Base {
protected: protected:
template <class... Ts> template <class... Ts>
singleton_mixin(Ts&&... args) : Base(std::forward<Ts>(args)...) { singleton_mixin(Ts&&... xs) : Base(std::forward<Ts>(xs)...) {
// nop // nop
} }
......
...@@ -80,8 +80,8 @@ class tuple_vals : public message_data { ...@@ -80,8 +80,8 @@ class tuple_vals : public message_data {
tuple_vals(const tuple_vals&) = default; tuple_vals(const tuple_vals&) = default;
template <class... Us> template <class... Us>
tuple_vals(Us&&... args) tuple_vals(Us&&... xs)
: m_data(std::forward<Us>(args)...), : m_data(std::forward<Us>(xs)...),
m_types{{tuple_vals_type_helper<Ts>::get()...}} { m_types{{tuple_vals_type_helper<Ts>::get()...}} {
// nop // nop
} }
......
...@@ -96,8 +96,8 @@ class intrusive_ptr : detail::comparable<intrusive_ptr<T>>, ...@@ -96,8 +96,8 @@ class intrusive_ptr : detail::comparable<intrusive_ptr<T>>,
} }
template <class... Ts> template <class... Ts>
void emplace(Ts&&... args) { void emplace(Ts&&... xs) {
reset(new T(std::forward<Ts>(args)...)); reset(new T(std::forward<Ts>(xs)...));
} }
intrusive_ptr& operator=(pointer ptr) { intrusive_ptr& operator=(pointer ptr) {
......
...@@ -38,8 +38,8 @@ typename std::enable_if< ...@@ -38,8 +38,8 @@ typename std::enable_if<
detail::is_memory_cached<T>::value, detail::is_memory_cached<T>::value,
intrusive_ptr<T> intrusive_ptr<T>
>::type >::type
make_counted(Ts&&... args) { make_counted(Ts&&... xs) {
return intrusive_ptr<T>(detail::memory::create<T>(std::forward<Ts>(args)...), return intrusive_ptr<T>(detail::memory::create<T>(std::forward<Ts>(xs)...),
false); false);
} }
...@@ -53,8 +53,8 @@ typename std::enable_if< ...@@ -53,8 +53,8 @@ typename std::enable_if<
!detail::is_memory_cached<T>::value, !detail::is_memory_cached<T>::value,
intrusive_ptr<T> intrusive_ptr<T>
>::type >::type
make_counted(Ts&&... args) { make_counted(Ts&&... xs) {
return intrusive_ptr<T>(new T(std::forward<Ts>(args)...), false); return intrusive_ptr<T>(new T(std::forward<Ts>(xs)...), false);
} }
} // namespace caf } // namespace caf
......
...@@ -281,7 +281,7 @@ class message { ...@@ -281,7 +281,7 @@ class message {
* } * }
* ~~~ * ~~~
*/ */
cli_res extract_opts(std::vector<cli_arg> args) const; cli_res extract_opts(std::vector<cli_arg> xs) const;
/** /**
* Queries whether the element at position `p` is of type `T`. * Queries whether the element at position `p` is of type `T`.
......
...@@ -102,8 +102,8 @@ class message_builder { ...@@ -102,8 +102,8 @@ class message_builder {
/** /**
* @copydoc message::extract_opts * @copydoc message::extract_opts
*/ */
inline message::cli_res extract_opts(std::vector<message::cli_arg> args) const { inline message::cli_res extract_opts(std::vector<message::cli_arg> xs) const {
return to_message().extract_opts(std::move(args)); return to_message().extract_opts(std::move(xs));
} }
/** /**
......
...@@ -17,8 +17,8 @@ ...@@ -17,8 +17,8 @@
* http://www.boost.org/LICENSE_1_0.txt. * * http://www.boost.org/LICENSE_1_0.txt. *
******************************************************************************/ ******************************************************************************/
#ifndef CAF_PARTIAL_FUNCTION_HPP #ifndef CAF_MESSAGE_HANDLER_HPP
#define CAF_PARTIAL_FUNCTION_HPP #define CAF_MESSAGE_HANDLER_HPP
#include <list> #include <list>
#include <vector> #include <vector>
...@@ -105,14 +105,13 @@ class message_handler { ...@@ -105,14 +105,13 @@ class message_handler {
/** /**
* Runs this handler and returns its (optional) result. * Runs this handler and returns its (optional) result.
*/ */
template <class T> inline optional<message> operator()(message& arg) {
optional<message> operator()(T&& arg) { return (m_impl) ? m_impl->invoke(arg) : none;
return (m_impl) ? m_impl->invoke(std::forward<T>(arg)) : none;
} }
/** /**
* Returns a new handler that concatenates this handler * Returns a new handler that concatenates this handler
* with a new handler from `args...`. * with a new handler from `xs...`.
*/ */
template <class... Ts> template <class... Ts>
typename std::conditional< typename std::conditional<
...@@ -122,10 +121,10 @@ class message_handler { ...@@ -122,10 +121,10 @@ class message_handler {
behavior, behavior,
message_handler message_handler
>::type >::type
or_else(Ts&&... args) const { or_else(Ts&&... xs) const {
// using a behavior is safe here, because we "cast" // using a behavior is safe here, because we "cast"
// it back to a message_handler when appropriate // it back to a message_handler when appropriate
behavior tmp{std::forward<Ts>(args)...}; behavior tmp{std::forward<Ts>(xs)...};
if (! tmp) { if (! tmp) {
return *this; return *this;
} }
...@@ -141,4 +140,4 @@ class message_handler { ...@@ -141,4 +140,4 @@ class message_handler {
} // namespace caf } // namespace caf
#endif // CAF_PARTIAL_FUNCTION_HPP #endif // CAF_MESSAGE_HANDLER_HPP
...@@ -55,7 +55,7 @@ class actor_widget : public Base { ...@@ -55,7 +55,7 @@ class actor_widget : public Base {
}; };
template <typename... Ts> template <typename... Ts>
actor_widget(Ts&&... args) : Base(std::forward<Ts>(args)...) { actor_widget(Ts&&... xs) : Base(std::forward<Ts>(xs)...) {
m_companion = make_counted<actor_companion>(); m_companion = make_counted<actor_companion>();
m_companion->on_enqueue([=](message_pointer ptr) { m_companion->on_enqueue([=](message_pointer ptr) {
qApp->postEvent(this, new event_type(std::move(ptr))); qApp->postEvent(this, new event_type(std::move(ptr)));
......
...@@ -94,16 +94,14 @@ class functor_based : public Base { ...@@ -94,16 +94,14 @@ class functor_based : public Base {
} }
template <class Token, typename F, typename T0, class... Ts> template <class Token, typename F, typename T0, class... Ts>
void set(Token t1, std::true_type t2, F fun, T0&& arg0, Ts&&... args) { void set(Token t1, std::true_type t2, F fun, T0&& x, Ts&&... xs) {
set(t1, t2, set(t1, t2, std::bind(fun, std::placeholders::_1, std::forward<T0>(x),
std::bind(fun, std::placeholders::_1, std::forward<T0>(arg0), std::forward<Ts>(xs)...));
std::forward<Ts>(args)...));
} }
template <class Token, typename F, typename T0, class... Ts> template <class Token, typename F, typename T0, class... Ts>
void set(Token t1, std::false_type t2, F fun, T0&& arg0, Ts&&... args) { void set(Token t1, std::false_type t2, F fun, T0&& x, Ts&&... xs) {
set(t1, t2, set(t1, t2, std::bind(fun, std::forward<T0>(x), std::forward<Ts>(xs)...));
std::bind(fun, std::forward<T0>(arg0), std::forward<Ts>(args)...));
} }
}; };
......
...@@ -151,15 +151,15 @@ auto to_guard(const atom_constant<V>&) -> decltype(to_guard(V)) { ...@@ -151,15 +151,15 @@ auto to_guard(const atom_constant<V>&) -> decltype(to_guard(V)) {
* Returns a generator for `match_case` objects. * Returns a generator for `match_case` objects.
*/ */
template <class... Ts> template <class... Ts>
auto on(const Ts&... args) auto on(const Ts&... xs)
-> detail::advanced_match_case_builder< -> detail::advanced_match_case_builder<
detail::type_list< detail::type_list<
decltype(to_guard(args))... decltype(to_guard(xs))...
>, >,
detail::type_list< detail::type_list<
typename detail::pattern_type<typename std::decay<Ts>::type>::type...> typename detail::pattern_type<typename std::decay<Ts>::type>::type...>
> { > {
return {detail::variadic_ctor{}, to_guard(args)...}; return {detail::variadic_ctor{}, to_guard(xs)...};
} }
/** /**
......
...@@ -36,7 +36,7 @@ template <class Derived, class Base = event_based_actor> ...@@ -36,7 +36,7 @@ template <class Derived, class Base = event_based_actor>
class sb_actor : public Base { class sb_actor : public Base {
public: public:
static_assert(std::is_base_of<event_based_actor, Base>::value, static_assert(std::is_base_of<event_based_actor, Base>::value,
"Base must be event_based_actor or a derived type"); "Base must be event_based_actor or a derived type");
/** /**
* Overrides {@link event_based_actor::make_behavior()} and sets * Overrides {@link event_based_actor::make_behavior()} and sets
...@@ -50,8 +50,9 @@ public: ...@@ -50,8 +50,9 @@ public:
using combined_type = sb_actor; using combined_type = sb_actor;
template <class... Ts> template <class... Ts>
sb_actor(Ts&&... args) sb_actor(Ts&&... xs) : Base(std::forward<Ts>(xs)...) {
: Base(std::forward<Ts>(args)...) {} // nop
}
}; };
} // namespace caf } // namespace caf
......
...@@ -38,14 +38,14 @@ namespace caf { ...@@ -38,14 +38,14 @@ namespace caf {
class execution_unit; class execution_unit;
/** /**
* Returns a newly spawned instance of type `C` using `args...` as constructor * Returns a newly spawned instance of type `C` using `xs...` as constructor
* arguments. The instance will be added to the job list of `host`. However, * arguments. The instance will be added to the job list of `host`. However,
* before the instance is launched, `before_launch_fun` will be called, e.g., * before the instance is launched, `before_launch_fun` will be called, e.g.,
* to join a group before the actor is running. * to join a group before the actor is running.
*/ */
template <class C, spawn_options Os, class BeforeLaunch, class... Ts> template <class C, spawn_options Os, class BeforeLaunch, class... Ts>
intrusive_ptr<C> spawn_impl(execution_unit* host, intrusive_ptr<C> spawn_impl(execution_unit* host,
BeforeLaunch before_launch_fun, Ts&&... args) { BeforeLaunch before_launch_fun, Ts&&... xs) {
static_assert(!std::is_base_of<blocking_actor, C>::value static_assert(!std::is_base_of<blocking_actor, C>::value
|| has_blocking_api_flag(Os), || has_blocking_api_flag(Os),
"C is derived from blocking_actor but " "C is derived from blocking_actor but "
...@@ -53,7 +53,7 @@ intrusive_ptr<C> spawn_impl(execution_unit* host, ...@@ -53,7 +53,7 @@ intrusive_ptr<C> spawn_impl(execution_unit* host,
static_assert(is_unbound(Os), static_assert(is_unbound(Os),
"top-level spawns cannot have monitor or link flag"); "top-level spawns cannot have monitor or link flag");
CAF_LOGF_TRACE(""); CAF_LOGF_TRACE("");
auto ptr = make_counted<C>(std::forward<Ts>(args)...); auto ptr = make_counted<C>(std::forward<Ts>(xs)...);
CAF_LOGF_DEBUG("spawned actor with ID " << ptr->id()); CAF_LOGF_DEBUG("spawned actor with ID " << ptr->id());
CAF_PUSH_AID(ptr->id()); CAF_PUSH_AID(ptr->id());
if (has_priority_aware_flag(Os)) { if (has_priority_aware_flag(Os)) {
...@@ -104,9 +104,9 @@ spawn_fwd(typename std::remove_reference<T>::type&& arg) noexcept { ...@@ -104,9 +104,9 @@ spawn_fwd(typename std::remove_reference<T>::type&& arg) noexcept {
*/ */
template <class C, spawn_options Os, typename BeforeLaunch, class... Ts> template <class C, spawn_options Os, typename BeforeLaunch, class... Ts>
intrusive_ptr<C> spawn_class(execution_unit* host, intrusive_ptr<C> spawn_class(execution_unit* host,
BeforeLaunch before_launch_fun, Ts&&... args) { BeforeLaunch before_launch_fun, Ts&&... xs) {
return spawn_impl<C, Os>(host, before_launch_fun, return spawn_impl<C, Os>(host, before_launch_fun,
spawn_fwd<Ts>(args)...); spawn_fwd<Ts>(xs)...);
} }
/** /**
...@@ -115,7 +115,7 @@ intrusive_ptr<C> spawn_class(execution_unit* host, ...@@ -115,7 +115,7 @@ intrusive_ptr<C> spawn_class(execution_unit* host,
* selects a proper implementation class and then delegates to `spawn_class`. * selects a proper implementation class and then delegates to `spawn_class`.
*/ */
template <spawn_options Os, typename BeforeLaunch, typename F, class... Ts> template <spawn_options Os, typename BeforeLaunch, typename F, class... Ts>
actor spawn_functor(execution_unit* eu, BeforeLaunch cb, F fun, Ts&&... args) { actor spawn_functor(execution_unit* eu, BeforeLaunch cb, F fun, Ts&&... xs) {
using trait = typename detail::get_callable_trait<F>::type; using trait = typename detail::get_callable_trait<F>::type;
using arg_types = typename trait::arg_types; using arg_types = typename trait::arg_types;
using first_arg = typename detail::tl_head<arg_types>::type; using first_arg = typename detail::tl_head<arg_types>::type;
...@@ -138,7 +138,7 @@ actor spawn_functor(execution_unit* eu, BeforeLaunch cb, F fun, Ts&&... args) { ...@@ -138,7 +138,7 @@ actor spawn_functor(execution_unit* eu, BeforeLaunch cb, F fun, Ts&&... args) {
"non-blocking functor-based actors " "non-blocking functor-based actors "
"cannot be spawned using the blocking_api flag"); "cannot be spawned using the blocking_api flag");
using impl_class = typename base_class::functor_based; using impl_class = typename base_class::functor_based;
return spawn_class<impl_class, Os>(eu, cb, fun, std::forward<Ts>(args)...); return spawn_class<impl_class, Os>(eu, cb, fun, std::forward<Ts>(xs)...);
} }
/** /**
...@@ -147,49 +147,49 @@ actor spawn_functor(execution_unit* eu, BeforeLaunch cb, F fun, Ts&&... args) { ...@@ -147,49 +147,49 @@ actor spawn_functor(execution_unit* eu, BeforeLaunch cb, F fun, Ts&&... args) {
*/ */
/** /**
* Returns a new actor of type `C` using `args...` as constructor * Returns a new actor of type `C` using `xs...` as constructor
* arguments. The behavior of `spawn` can be modified by setting `Os`, e.g., * arguments. The behavior of `spawn` can be modified by setting `Os`, e.g.,
* to opt-out of the cooperative scheduling. * to opt-out of the cooperative scheduling.
*/ */
template <class C, spawn_options Os = no_spawn_options, class... Ts> template <class C, spawn_options Os = no_spawn_options, class... Ts>
actor spawn(Ts&&... args) { actor spawn(Ts&&... xs) {
return spawn_class<C, Os>(nullptr, empty_before_launch_callback{}, return spawn_class<C, Os>(nullptr, empty_before_launch_callback{},
std::forward<Ts>(args)...); std::forward<Ts>(xs)...);
} }
/** /**
* Returns a new functor-based actor. The first argument must be the functor, * Returns a new functor-based actor. The first argument must be the functor,
* the remainder of `args...` is used to invoke the functor. * the remainder of `xs...` is used to invoke the functor.
* The behavior of `spawn` can be modified by setting `Os`, e.g., * The behavior of `spawn` can be modified by setting `Os`, e.g.,
* to opt-out of the cooperative scheduling. * to opt-out of the cooperative scheduling.
*/ */
template <spawn_options Os = no_spawn_options, class... Ts> template <spawn_options Os = no_spawn_options, class... Ts>
actor spawn(Ts&&... args) { actor spawn(Ts&&... xs) {
static_assert(sizeof...(Ts) > 0, "too few arguments provided"); static_assert(sizeof...(Ts) > 0, "too few arguments provided");
return spawn_functor<Os>(nullptr, empty_before_launch_callback{}, return spawn_functor<Os>(nullptr, empty_before_launch_callback{},
std::forward<Ts>(args)...); std::forward<Ts>(xs)...);
} }
/** /**
* Returns a new actor that immediately, i.e., before this function * Returns a new actor that immediately, i.e., before this function
* returns, joins `grp` of type `C` using `args` as constructor arguments * returns, joins `grp` of type `C` using `xs` as constructor arguments
*/ */
template <class C, spawn_options Os = no_spawn_options, class... Ts> template <class C, spawn_options Os = no_spawn_options, class... Ts>
actor spawn_in_group(const group& grp, Ts&&... args) { actor spawn_in_group(const group& grp, Ts&&... xs) {
return spawn_class<C, Os>(nullptr, group_subscriber{grp}, return spawn_class<C, Os>(nullptr, group_subscriber{grp},
std::forward<Ts>(args)...); std::forward<Ts>(xs)...);
} }
/** /**
* Returns a new actor that immediately, i.e., before this function * Returns a new actor that immediately, i.e., before this function
* returns, joins `grp`. The first element of `args` must * returns, joins `grp`. The first element of `xs` must
* be the functor, the remaining arguments its arguments. * be the functor, the remaining arguments its arguments.
*/ */
template <spawn_options Os = no_spawn_options, class... Ts> template <spawn_options Os = no_spawn_options, class... Ts>
actor spawn_in_group(const group& grp, Ts&&... args) { actor spawn_in_group(const group& grp, Ts&&... xs) {
static_assert(sizeof...(Ts) > 0, "too few arguments provided"); static_assert(sizeof...(Ts) > 0, "too few arguments provided");
return spawn_functor<Os>(nullptr, group_subscriber{grp}, return spawn_functor<Os>(nullptr, group_subscriber{grp},
std::forward<Ts>(args)...); std::forward<Ts>(xs)...);
} }
/** /**
...@@ -229,11 +229,11 @@ class functor_based_typed_actor : public typed_event_based_actor<Sigs...> { ...@@ -229,11 +229,11 @@ class functor_based_typed_actor : public typed_event_based_actor<Sigs...> {
using one_arg_fun2 = std::function<void(pointer)>; using one_arg_fun2 = std::function<void(pointer)>;
/** /**
* Creates a new instance from given functor, binding `args...` * Creates a new instance from given functor, binding `xs...`
* to the functor. * to the functor.
*/ */
template <class F, class... Ts> template <class F, class... Ts>
functor_based_typed_actor(F fun, Ts&&... args) { functor_based_typed_actor(F fun, Ts&&... xs) {
using trait = typename detail::get_callable_trait<F>::type; using trait = typename detail::get_callable_trait<F>::type;
using arg_types = typename trait::arg_types; using arg_types = typename trait::arg_types;
using result_type = typename trait::result_type; using result_type = typename trait::result_type;
...@@ -243,7 +243,7 @@ class functor_based_typed_actor : public typed_event_based_actor<Sigs...> { ...@@ -243,7 +243,7 @@ class functor_based_typed_actor : public typed_event_based_actor<Sigs...> {
typename detail::tl_head<arg_types>::type, pointer>::value; typename detail::tl_head<arg_types>::type, pointer>::value;
std::integral_constant<bool, returns_behavior> token1; std::integral_constant<bool, returns_behavior> token1;
std::integral_constant<bool, uses_first_arg> token2; std::integral_constant<bool, uses_first_arg> token2;
set(token1, token2, std::move(fun), std::forward<Ts>(args)...); set(token1, token2, std::move(fun), std::forward<Ts>(xs)...);
} }
protected: protected:
...@@ -277,16 +277,16 @@ class functor_based_typed_actor : public typed_event_based_actor<Sigs...> { ...@@ -277,16 +277,16 @@ class functor_based_typed_actor : public typed_event_based_actor<Sigs...> {
// (false_type, false_type) is an invalid functor for typed actors // (false_type, false_type) is an invalid functor for typed actors
template <class Token, typename F, typename T0, class... Ts> template <class Token, typename F, typename T0, class... Ts>
void set(Token t1, std::true_type t2, F fun, T0&& arg0, Ts&&... args) { void set(Token t1, std::true_type t2, F fun, T0&& arg0, Ts&&... xs) {
set(t1, t2, set(t1, t2,
std::bind(fun, std::placeholders::_1, std::forward<T0>(arg0), std::bind(fun, std::placeholders::_1, std::forward<T0>(arg0),
std::forward<Ts>(args)...)); std::forward<Ts>(xs)...));
} }
template <class Token, typename F, typename T0, class... Ts> template <class Token, typename F, typename T0, class... Ts>
void set(Token t1, std::false_type t2, F fun, T0&& arg0, Ts&&... args) { void set(Token t1, std::false_type t2, F fun, T0&& arg0, Ts&&... xs) {
set(t1, t2, set(t1, t2,
std::bind(fun, std::forward<T0>(arg0), std::forward<Ts>(args)...)); std::bind(fun, std::forward<T0>(arg0), std::forward<Ts>(xs)...));
} }
// we convert any of the three accepted signatures to this one // we convert any of the three accepted signatures to this one
...@@ -311,14 +311,14 @@ struct infer_typed_actor_base<void, typed_event_based_actor<Sigs...>*> { ...@@ -311,14 +311,14 @@ struct infer_typed_actor_base<void, typed_event_based_actor<Sigs...>*> {
}; };
/** /**
* Returns a new typed actor of type `C` using `args...` as * Returns a new typed actor of type `C` using `xs...` as
* constructor arguments. * constructor arguments.
*/ */
template <class C, spawn_options Os = no_spawn_options, class... Ts> template <class C, spawn_options Os = no_spawn_options, class... Ts>
typename actor_handle_from_signature_list<typename C::signatures>::type typename actor_handle_from_signature_list<typename C::signatures>::type
spawn_typed(Ts&&... args) { spawn_typed(Ts&&... xs) {
return spawn_class<C, Os>(nullptr, empty_before_launch_callback{}, return spawn_class<C, Os>(nullptr, empty_before_launch_callback{},
std::forward<Ts>(args)...); std::forward<Ts>(xs)...);
} }
/** /**
...@@ -331,7 +331,7 @@ typename infer_typed_actor_handle< ...@@ -331,7 +331,7 @@ typename infer_typed_actor_handle<
typename detail::get_callable_trait<F>::arg_types typename detail::get_callable_trait<F>::arg_types
>::type >::type
>::type >::type
spawn_typed_functor(execution_unit* eu, BeforeLaunch bl, F fun, Ts&&... args) { spawn_typed_functor(execution_unit* eu, BeforeLaunch bl, F fun, Ts&&... xs) {
using impl = using impl =
typename infer_typed_actor_base< typename infer_typed_actor_base<
typename detail::get_callable_trait<F>::result_type, typename detail::get_callable_trait<F>::result_type,
...@@ -339,12 +339,12 @@ spawn_typed_functor(execution_unit* eu, BeforeLaunch bl, F fun, Ts&&... args) { ...@@ -339,12 +339,12 @@ spawn_typed_functor(execution_unit* eu, BeforeLaunch bl, F fun, Ts&&... args) {
typename detail::get_callable_trait<F>::arg_types typename detail::get_callable_trait<F>::arg_types
>::type >::type
>::type; >::type;
return spawn_class<impl, Os>(eu, bl, fun, std::forward<Ts>(args)...); return spawn_class<impl, Os>(eu, bl, fun, std::forward<Ts>(xs)...);
} }
/** /**
* Returns a new typed actor from a functor. The first element * Returns a new typed actor from a functor. The first element
* of `args` must be the functor, the remaining arguments are used to * of `xs` must be the functor, the remaining arguments are used to
* invoke the functor. This function delegates its arguments to * invoke the functor. This function delegates its arguments to
* `spawn_typed_functor`. * `spawn_typed_functor`.
*/ */
...@@ -355,9 +355,9 @@ typename infer_typed_actor_handle< ...@@ -355,9 +355,9 @@ typename infer_typed_actor_handle<
typename detail::get_callable_trait<F>::arg_types typename detail::get_callable_trait<F>::arg_types
>::type >::type
>::type >::type
spawn_typed(F fun, Ts&&... args) { spawn_typed(F fun, Ts&&... xs) {
return spawn_typed_functor<Os>(nullptr, empty_before_launch_callback{}, return spawn_typed_functor<Os>(nullptr, empty_before_launch_callback{},
std::move(fun), std::forward<Ts>(args)...); std::move(fun), std::forward<Ts>(xs)...);
} }
/** @} */ /** @} */
......
...@@ -32,23 +32,27 @@ ...@@ -32,23 +32,27 @@
namespace caf { namespace caf {
template <class C, template <class C,
spawn_options Os = no_spawn_options, spawn_options Os = no_spawn_options,
typename BeforeLaunch = std::function<void (C*)>, class BeforeLaunch = std::function<void (C*)>,
class... Ts> class... Ts>
intrusive_ptr<C> spawn_class(execution_unit* host, intrusive_ptr<C> spawn_class(execution_unit* host,
BeforeLaunch before_launch_fun, Ts&&... args); BeforeLaunch before_launch_fun,
Ts&&... xs);
template <spawn_options Os = no_spawn_options, template <spawn_options Os = no_spawn_options,
typename BeforeLaunch = void (*)(abstract_actor*), class BeforeLaunch = void (*)(abstract_actor*),
typename F = behavior (*)(), class... Ts> class F = behavior (*)(),
actor spawn_functor(execution_unit* host, BeforeLaunch before_launch_fun, F fun, class... Ts>
Ts&&... args); actor spawn_functor(execution_unit* host,
BeforeLaunch before_launch_fun,
F fun,
Ts&&... xs);
class group_subscriber { class group_subscriber {
public: public:
inline group_subscriber(const group& grp) : m_grp(grp) {
inline group_subscriber(const group& grp) : m_grp(grp) {} // nop
}
template <class T> template <class T>
inline void operator()(T* ptr) const { inline void operator()(T* ptr) const {
...@@ -56,9 +60,7 @@ class group_subscriber { ...@@ -56,9 +60,7 @@ class group_subscriber {
} }
private: private:
group m_grp; group m_grp;
}; };
struct empty_before_launch_callback { struct empty_before_launch_callback {
...@@ -69,7 +71,7 @@ struct empty_before_launch_callback { ...@@ -69,7 +71,7 @@ struct empty_before_launch_callback {
}; };
/****************************************************************************** /******************************************************************************
* typed actors * * typed actors *
******************************************************************************/ ******************************************************************************/
template <class TypedBehavior, class FirstArg> template <class TypedBehavior, class FirstArg>
...@@ -102,7 +104,7 @@ typename infer_typed_actor_handle< ...@@ -102,7 +104,7 @@ typename infer_typed_actor_handle<
typename detail::get_callable_trait<F>::arg_types typename detail::get_callable_trait<F>::arg_types
>::type >::type
>::type >::type
spawn_typed_functor(execution_unit*, BeforeLaunch bl, F fun, Ts&&... args); spawn_typed_functor(execution_unit*, BeforeLaunch bl, F fun, Ts&&... xs);
} // namespace caf } // namespace caf
......
...@@ -63,13 +63,15 @@ std::string join(const Container& c, const std::string& glue) { ...@@ -63,13 +63,15 @@ std::string join(const Container& c, const std::string& glue) {
} }
// end of recursion // end of recursion
inline void splice(std::string&, const std::string&) { } inline void splice(std::string&, const std::string&) {
// nop
}
template <class T, class... Ts> template <class T, class... Ts>
void splice(std::string& str, const std::string& glue, T&& arg, Ts&&... args) { void splice(std::string& str, const std::string& glue, T&& arg, Ts&&... xs) {
str += glue; str += glue;
str += std::forward<T>(arg); str += std::forward<T>(arg);
splice(str, glue, std::forward<Ts>(args)...); splice(str, glue, std::forward<Ts>(xs)...);
} }
template <ptrdiff_t WhatSize, ptrdiff_t WithSize> template <ptrdiff_t WhatSize, ptrdiff_t WithSize>
......
...@@ -51,7 +51,7 @@ struct uniform_value_t { ...@@ -51,7 +51,7 @@ struct uniform_value_t {
}; };
template <class T, class... Ts> template <class T, class... Ts>
uniform_value make_uniform_value(const uniform_type_info* uti, Ts&&... args) { uniform_value make_uniform_value(const uniform_type_info* uti, Ts&&... xs) {
struct container : uniform_value_t { struct container : uniform_value_t {
T value; T value;
container(const uniform_type_info* ptr, T arg) : value(std::move(arg)) { container(const uniform_type_info* ptr, T arg) : value(std::move(arg)) {
...@@ -62,7 +62,7 @@ uniform_value make_uniform_value(const uniform_type_info* uti, Ts&&... args) { ...@@ -62,7 +62,7 @@ uniform_value make_uniform_value(const uniform_type_info* uti, Ts&&... args) {
return uniform_value{new container(ti, value)}; return uniform_value{new container(ti, value)};
} }
}; };
return uniform_value{new container(uti, T(std::forward<Ts>(args)...))}; return uniform_value{new container(uti, T(std::forward<Ts>(xs)...))};
} }
/** /**
......
...@@ -226,8 +226,8 @@ class local_group_proxy : public local_group { ...@@ -226,8 +226,8 @@ class local_group_proxy : public local_group {
using super = local_group; using super = local_group;
template <class... Ts> template <class... Ts>
local_group_proxy(actor remote_broker, Ts&&... args) local_group_proxy(actor remote_broker, Ts&&... xs)
: super(false, std::forward<Ts>(args)...) { : super(false, std::forward<Ts>(xs)...) {
CAF_REQUIRE(m_broker == invalid_actor); CAF_REQUIRE(m_broker == invalid_actor);
CAF_REQUIRE(remote_broker != invalid_actor); CAF_REQUIRE(remote_broker != invalid_actor);
m_broker = std::move(remote_broker); m_broker = std::move(remote_broker);
......
...@@ -120,7 +120,8 @@ message message::extract_impl(size_t start, message_handler handler) const { ...@@ -120,7 +120,8 @@ message message::extract_impl(size_t start, message_handler handler) const {
auto s = size(); auto s = size();
for (size_t i = start; i < s; ++i) { for (size_t i = start; i < s; ++i) {
for (size_t n = (s - i) ; n > 0; --n) { for (size_t n = (s - i) ; n > 0; --n) {
auto res = handler(slice(i, n)); auto next_slice = slice(i, n);
auto res = handler(next_slice);
if (res) { if (res) {
std::vector<size_t> mapping(s); std::vector<size_t> mapping(s);
std::iota(mapping.begin(), mapping.end(), size_t{0}); std::iota(mapping.begin(), mapping.end(), size_t{0});
...@@ -142,7 +143,7 @@ message message::extract(message_handler handler) const { ...@@ -142,7 +143,7 @@ message message::extract(message_handler handler) const {
return extract_impl(0, handler); return extract_impl(0, handler);
} }
message::cli_res message::extract_opts(std::vector<cli_arg> cliargs) const { message::cli_res message::extract_opts(std::vector<cli_arg> xs) const {
std::set<std::string> opts; std::set<std::string> opts;
cli_arg dummy{"help,h", ""}; cli_arg dummy{"help,h", ""};
std::map<std::string, cli_arg*> shorts; std::map<std::string, cli_arg*> shorts;
...@@ -150,7 +151,7 @@ message::cli_res message::extract_opts(std::vector<cli_arg> cliargs) const { ...@@ -150,7 +151,7 @@ message::cli_res message::extract_opts(std::vector<cli_arg> cliargs) const {
shorts["-h"] = &dummy; shorts["-h"] = &dummy;
shorts["-?"] = &dummy; shorts["-?"] = &dummy;
longs["--help"] = &dummy; longs["--help"] = &dummy;
for (auto& cliarg : cliargs) { for (auto& cliarg : xs) {
std::vector<std::string> s; std::vector<std::string> s;
split(s, cliarg.name, is_any_of(","), token_compress_on); split(s, cliarg.name, is_any_of(","), token_compress_on);
if (s.size() == 2 && s.back().size() == 1) { if (s.size() == 2 && s.back().size() == 1) {
...@@ -225,7 +226,7 @@ message::cli_res message::extract_opts(std::vector<cli_arg> cliargs) const { ...@@ -225,7 +226,7 @@ message::cli_res message::extract_opts(std::vector<cli_arg> cliargs) const {
} }
}); });
size_t name_width = 0; size_t name_width = 0;
for (auto& ca : cliargs) { for (auto& ca : xs) {
// name field contains either only "--<long_name>" or // name field contains either only "--<long_name>" or
// "-<short name> [--<long name>]" depending on whether or not // "-<short name> [--<long name>]" depending on whether or not
// a ',' appears in the name // a ',' appears in the name
...@@ -240,7 +241,7 @@ message::cli_res message::extract_opts(std::vector<cli_arg> cliargs) const { ...@@ -240,7 +241,7 @@ message::cli_res message::extract_opts(std::vector<cli_arg> cliargs) const {
std::ostringstream oss; std::ostringstream oss;
oss << std::left; oss << std::left;
oss << "Allowed options:" << std::endl; oss << "Allowed options:" << std::endl;
for (auto& ca : cliargs) { for (auto& ca : xs) {
std::string lhs; std::string lhs;
auto separator = ca.name.find(','); auto separator = ca.name.find(',');
if (separator == std::string::npos) { if (separator == std::string::npos) {
......
...@@ -559,14 +559,16 @@ class default_meta_message : public uniform_type_info { ...@@ -559,14 +559,16 @@ class default_meta_message : public uniform_type_info {
template <class Iterator> template <class Iterator>
struct builtin_types_helper { struct builtin_types_helper {
Iterator pos; Iterator pos;
builtin_types_helper(Iterator first) : pos(first) {} builtin_types_helper(Iterator first) : pos(first) {
// nop
}
void operator()() const { void operator()() const {
// end of recursion // end of recursion
} }
template <class T, class... Ts> template <class T, class... Ts>
void operator()(T& arg, Ts&... args) { void operator()(T& x, Ts&... xs) {
*pos++ = &arg; *pos++ = &x;
(*this)(args...); (*this)(xs...);
} }
}; };
......
...@@ -109,9 +109,9 @@ class middleman : public detail::abstract_singleton { ...@@ -109,9 +109,9 @@ class middleman : public detail::abstract_singleton {
* Adds a new hook to the middleman. * Adds a new hook to the middleman.
*/ */
template<class C, typename... Ts> template<class C, typename... Ts>
void add_hook(Ts&&... args) { void add_hook(Ts&&... xs) {
// if only we could move a unique_ptr into a lambda in C++11 // if only we could move a unique_ptr into a lambda in C++11
auto ptr = new C(std::forward<Ts>(args)...); auto ptr = new C(std::forward<Ts>(xs)...);
backend().dispatch([=] { backend().dispatch([=] {
ptr->next.swap(m_hooks); ptr->next.swap(m_hooks);
m_hooks.reset(ptr); m_hooks.reset(ptr);
......
...@@ -48,11 +48,11 @@ actor spawn_io(F fun, Ts&&... xs) { ...@@ -48,11 +48,11 @@ actor spawn_io(F fun, Ts&&... xs) {
template <spawn_options Os = no_spawn_options, template <spawn_options Os = no_spawn_options,
typename F = std::function<void(broker*)>, class... Ts> typename F = std::function<void(broker*)>, class... Ts>
actor spawn_io_client(F fun, const std::string& host, actor spawn_io_client(F fun, const std::string& host,
uint16_t port, Ts&&... args) { uint16_t port, Ts&&... xs) {
// provoke compiler error early // provoke compiler error early
using fun_res = decltype(fun(static_cast<broker*>(nullptr), using fun_res = decltype(fun(static_cast<broker*>(nullptr),
connection_handle{}, connection_handle{},
std::forward<Ts>(args)...)); std::forward<Ts>(xs)...));
// prevent warning about unused local type // prevent warning about unused local type
static_assert(std::is_same<fun_res, fun_res>::value, static_assert(std::is_same<fun_res, fun_res>::value,
"your compiler is lying to you"); "your compiler is lying to you");
...@@ -62,7 +62,7 @@ actor spawn_io_client(F fun, const std::string& host, ...@@ -62,7 +62,7 @@ actor spawn_io_client(F fun, const std::string& host,
auto mfptr = &broker::functor_based::init<F, connection_handle, Ts...>; auto mfptr = &broker::functor_based::init<F, connection_handle, Ts...>;
using bi = std::function<void (broker::functor_based*, F, connection_handle)>; using bi = std::function<void (broker::functor_based*, F, connection_handle)>;
using namespace std::placeholders; using namespace std::placeholders;
bi init = std::bind(mfptr, _1, _2, _3, std::forward<Ts>(args)...); bi init = std::bind(mfptr, _1, _2, _3, std::forward<Ts>(xs)...);
return spawn_class<broker::functor_based>( return spawn_class<broker::functor_based>(
nullptr, nullptr,
[&](broker::functor_based* ptr) { [&](broker::functor_based* ptr) {
...@@ -77,12 +77,12 @@ actor spawn_io_client(F fun, const std::string& host, ...@@ -77,12 +77,12 @@ actor spawn_io_client(F fun, const std::string& host,
*/ */
template <spawn_options Os = no_spawn_options, template <spawn_options Os = no_spawn_options,
class F = std::function<void(broker*)>, class... Ts> class F = std::function<void(broker*)>, class... Ts>
actor spawn_io_server(F fun, uint16_t port, Ts&&... args) { actor spawn_io_server(F fun, uint16_t port, Ts&&... xs) {
// same workaround as above // same workaround as above
auto mfptr = &broker::functor_based::init<F, Ts...>; auto mfptr = &broker::functor_based::init<F, Ts...>;
using bi = std::function<void (broker::functor_based*, F)>; using bi = std::function<void (broker::functor_based*, F)>;
using namespace std::placeholders; using namespace std::placeholders;
bi init = std::bind(mfptr, _1, _2, std::forward<Ts>(args)...); bi init = std::bind(mfptr, _1, _2, std::forward<Ts>(xs)...);
return spawn_class<broker::functor_based>( return spawn_class<broker::functor_based>(
nullptr, nullptr,
[&](broker::functor_based* ptr) { [&](broker::functor_based* ptr) {
......
...@@ -84,10 +84,10 @@ bool cc_valid_socket(caf::io::network::native_socket fd) { ...@@ -84,10 +84,10 @@ bool cc_valid_socket(caf::io::network::native_socket fd) {
// calls a C function and throws a `network_error` if `p` returns false // calls a C function and throws a `network_error` if `p` returns false
template <class Predicate, class F, class... Ts> template <class Predicate, class F, class... Ts>
auto ccall(Predicate p, const char* errmsg, F f, Ts&&... args) auto ccall(Predicate p, const char* errmsg, F f, Ts&&... xs)
-> decltype(f(std::forward<Ts>(args)...)) { -> decltype(f(std::forward<Ts>(xs)...)) {
using namespace caf::io::network; using namespace caf::io::network;
auto result = f(std::forward<Ts>(args)...); auto result = f(std::forward<Ts>(xs)...);
if (!p(result)) { if (!p(result)) {
std::ostringstream oss; std::ostringstream oss;
oss << errmsg << ": " << last_socket_error_as_string() oss << errmsg << ": " << last_socket_error_as_string()
......
...@@ -55,10 +55,12 @@ void foo() { ...@@ -55,10 +55,12 @@ void foo() {
} }
struct send_to_self { struct send_to_self {
send_to_self(blocking_actor* self) : m_self(self) {} send_to_self(blocking_actor* self) : m_self(self) {
// nop
}
template <class... Ts> template <class... Ts>
void operator()(Ts&&... args) { void operator()(Ts&&... xs) {
m_self->send(m_self, std::forward<Ts>(args)...); m_self->send(m_self, std::forward<Ts>(xs)...);
} }
blocking_actor* m_self; blocking_actor* m_self;
}; };
......
...@@ -50,11 +50,11 @@ void fill_mb(message_builder& mb, const T& x, const Ts&... xs) { ...@@ -50,11 +50,11 @@ void fill_mb(message_builder& mb, const T& x, const Ts&... xs) {
} }
template <class... Ts> template <class... Ts>
ptrdiff_t invoked(message_handler expr, const Ts&... args) { ptrdiff_t invoked(message_handler expr, const Ts&... xs) {
vector<message> msgs; vector<message> msgs;
msgs.push_back(make_message(args...)); msgs.push_back(make_message(xs...));
message_builder mb; message_builder mb;
fill_mb(mb, args...); fill_mb(mb, xs...);
msgs.push_back(mb.to_message()); msgs.push_back(mb.to_message());
set<ptrdiff_t> results; set<ptrdiff_t> results;
for (auto& msg : msgs) { for (auto& msg : msgs) {
......
...@@ -85,9 +85,9 @@ void test_extract3() { ...@@ -85,9 +85,9 @@ void test_extract3() {
} }
void test_extract_opts() { void test_extract_opts() {
auto f = [](std::vector<std::string> args) { auto f = [](std::vector<std::string> xs) {
std::string filename; std::string filename;
auto res = message_builder(args.begin(), args.end()).extract_opts({ auto res = message_builder(xs.begin(), xs.end()).extract_opts({
{"version,v", "print version"}, {"version,v", "print version"},
{"file,f", "set output file", filename}, {"file,f", "set output file", filename},
{"whatever", "do whatever"} {"whatever", "do whatever"}
......
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