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