Commit 0c4ebcfe authored by Dominik Charousset's avatar Dominik Charousset

Fix build on GCC 4.7

parent edbc7b37
...@@ -20,6 +20,8 @@ ...@@ -20,6 +20,8 @@
#ifndef CAF_CHECK_TYPED_INPUT_HPP #ifndef CAF_CHECK_TYPED_INPUT_HPP
#define CAF_CHECK_TYPED_INPUT_HPP #define CAF_CHECK_TYPED_INPUT_HPP
#include "caf/typed_actor.hpp"
#include "caf/detail/type_list.hpp" #include "caf/detail/type_list.hpp"
#include "caf/detail/typed_actor_util.hpp" #include "caf/detail/typed_actor_util.hpp"
...@@ -29,9 +31,9 @@ namespace caf { ...@@ -29,9 +31,9 @@ namespace caf {
* Checks whether `R` does support an input of type `{Ls...}` via a * Checks whether `R` does support an input of type `{Ls...}` via a
* static assertion (always returns 0). * static assertion (always returns 0).
*/ */
template <template <class...> class R, class... Rs, template <class... Rs, class... Ls>
template <class...> class L, class... Ls> void check_typed_input(const typed_actor<Rs...>&,
constexpr int check_typed_input(const R<Rs...>&, const L<Ls...>&) { const detail::type_list<Ls...>&) {
static_assert(detail::tl_find< static_assert(detail::tl_find<
detail::type_list<Ls...>, detail::type_list<Ls...>,
atom_value atom_value
...@@ -41,8 +43,8 @@ constexpr int check_typed_input(const R<Rs...>&, const L<Ls...>&) { ...@@ -41,8 +43,8 @@ constexpr int check_typed_input(const R<Rs...>&, const L<Ls...>&) {
static_assert(detail::tl_find_if< static_assert(detail::tl_find_if<
detail::type_list<Rs...>, detail::type_list<Rs...>,
detail::input_is<detail::type_list<Ls...>>::template eval detail::input_is<detail::type_list<Ls...>>::template eval
>::value >= 0, "typed actor does not support given input"); >::value >= 0,
return 0; "typed actor does not support given input");
} }
} // namespace caf } // namespace caf
......
...@@ -164,10 +164,13 @@ class local_actor : public abstract_actor { ...@@ -164,10 +164,13 @@ class local_actor : public abstract_actor {
*/ */
template <class... Rs, class... Vs> template <class... Rs, class... Vs>
void send(const typed_actor<Rs...>& whom, Vs&&... vs) { void send(const typed_actor<Rs...>& whom, Vs&&... vs) {
check_typed_input(whom, using token =
detail::type_list<typename detail::implicit_conversions< detail::type_list<
typename std::decay<Vs>::type typename detail::implicit_conversions<
>::type...>{}); typename std::decay<Vs>::type
>::type...>;
token tk;
check_typed_input(whom, tk);
fast_send(message_priority::normal, whom, std::forward<Vs>(vs)...); fast_send(message_priority::normal, whom, std::forward<Vs>(vs)...);
} }
......
...@@ -119,7 +119,18 @@ class sync_sender_impl : public Base { ...@@ -119,7 +119,18 @@ class sync_sender_impl : public Base {
>::type, >::type,
HandleTag> HandleTag>
sync_send(const typed_actor<Rs...>& dest, Vs&&... vs) { sync_send(const typed_actor<Rs...>& dest, Vs&&... vs) {
return sync_send(message_priority::normal, dest, std::forward<Vs>(vs)...); static_assert(sizeof...(Vs) > 0, "no message to send");
using token =
detail::type_list<
typename detail::implicit_conversions<
typename std::decay<Vs>::type
>::type...>;
token tk;
check_typed_input(dest, tk);
return {dptr()->sync_send_impl(message_priority::normal,
actor_cast<actor>(dest),
make_message(std::forward<Vs>(vs)...)),
dptr()};
} }
/**************************************************************************** /****************************************************************************
......
...@@ -36,92 +36,104 @@ namespace caf { ...@@ -36,92 +36,104 @@ namespace caf {
/** /**
* Sends `to` a message under the identity of `from` with priority `prio`. * Sends `to` a message under the identity of `from` with priority `prio`.
*/ */
template <class... Ts> template <class... Vs>
void send_as(const actor& from, message_priority prio, void send_as(const actor& from, message_priority prio,
const channel& to, Ts&&... vs) { const channel& to, Vs&&... vs) {
if (!to) { if (!to) {
return; return;
} }
message_id mid; message_id mid;
to->enqueue(from.address(), to->enqueue(from.address(),
prio == message_priority::high ? mid.with_high_priority() : mid, prio == message_priority::high ? mid.with_high_priority() : mid,
make_message(std::forward<Ts>(vs)...), nullptr); make_message(std::forward<Vs>(vs)...), nullptr);
} }
/** /**
* Sends `to` a message under the identity of `from`. * Sends `to` a message under the identity of `from`.
*/ */
template <class... Ts> template <class... Vs>
void send_as(const actor& from, const channel& to, Ts&&... vs) { void send_as(const actor& from, const channel& to, Vs&&... vs) {
send_as(from, message_priority::normal, to, std::forward<Ts>(vs)...); send_as(from, message_priority::normal, to, std::forward<Vs>(vs)...);
} }
/** /**
* Sends `to` a message under the identity of `from` with priority `prio`. * Sends `to` a message under the identity of `from` with priority `prio`.
*/ */
template <class... Rs, class... Ts> template <class... Rs, class... Vs>
void send_as(const actor& from, message_priority prio, void send_as(const actor& from, message_priority prio,
const typed_actor<Rs...>& to, Ts&&... vs) { const typed_actor<Rs...>& to, Vs&&... vs) {
check_typed_input(to, using token =
detail::type_list<typename detail::implicit_conversions< detail::type_list<
typename std::decay<Ts>::type typename detail::implicit_conversions<
>::type...>{}); typename std::decay<Vs>::type
send_as(from, prio, actor_cast<channel>(to), std::forward<Ts>(vs)...); >::type...>;
token tk;
check_typed_input(to, tk);
send_as(from, prio, actor_cast<channel>(to), std::forward<Vs>(vs)...);
} }
/** /**
* Sends `to` a message under the identity of `from`. * Sends `to` a message under the identity of `from`.
*/ */
template <class... Rs, class... Ts> template <class... Rs, class... Vs>
void send_as(const actor& from, const typed_actor<Rs...>& to, Ts&&... vs) { void send_as(const actor& from, const typed_actor<Rs...>& to, Vs&&... vs) {
check_typed_input(to, using token =
detail::type_list<typename detail::implicit_conversions< detail::type_list<
typename std::decay<Ts>::type typename detail::implicit_conversions<
>::type...>{}); typename std::decay<Vs>::type
>::type...>;
token tk;
check_typed_input(to, tk);
send_as(from, message_priority::normal, send_as(from, message_priority::normal,
actor_cast<channel>(to), std::forward<Ts>(vs)...); actor_cast<channel>(to), std::forward<Vs>(vs)...);
} }
/** /**
* Anonymously sends `to` a message with priority `prio`. * Anonymously sends `to` a message with priority `prio`.
*/ */
template <class... Ts> template <class... Vs>
void anon_send(message_priority prio, const channel& to, Ts&&... vs) { void anon_send(message_priority prio, const channel& to, Vs&&... vs) {
send_as(invalid_actor, prio, to, std::forward<Ts>(vs)...); send_as(invalid_actor, prio, to, std::forward<Vs>(vs)...);
} }
/** /**
* Anonymously sends `to` a message. * Anonymously sends `to` a message.
*/ */
template <class... Ts> template <class... Vs>
void anon_send(const channel& to, Ts&&... vs) { void anon_send(const channel& to, Vs&&... vs) {
send_as(invalid_actor, message_priority::normal, to, std::forward<Ts>(vs)...); send_as(invalid_actor, message_priority::normal, to, std::forward<Vs>(vs)...);
} }
/** /**
* Anonymously sends `to` a message with priority `prio`. * Anonymously sends `to` a message with priority `prio`.
*/ */
template <class... Rs, class... Ts> template <class... Rs, class... Vs>
void anon_send(message_priority prio, const typed_actor<Rs...>& to, void anon_send(message_priority prio, const typed_actor<Rs...>& to,
Ts&&... vs) { Vs&&... vs) {
check_typed_input(to, using token =
detail::type_list<typename detail::implicit_conversions< detail::type_list<
typename std::decay<Ts>::type typename detail::implicit_conversions<
>::type...>{}); typename std::decay<Vs>::type
anon_send(prio, actor_cast<channel>(to), std::forward<Ts>(vs)...); >::type...>;
token tk;
check_typed_input(to, tk);
anon_send(prio, actor_cast<channel>(to), std::forward<Vs>(vs)...);
} }
/** /**
* Anonymously sends `to` a message. * Anonymously sends `to` a message.
*/ */
template <class... Rs, class... Ts> template <class... Rs, class... Vs>
void anon_send(const typed_actor<Rs...>& to, Ts&&... vs) { void anon_send(const typed_actor<Rs...>& to, Vs&&... vs) {
check_typed_input(to, using token =
detail::type_list<typename detail::implicit_conversions< detail::type_list<
typename std::decay<Ts>::type typename detail::implicit_conversions<
>::type...>{}); typename std::decay<Vs>::type
>::type...>;
token tk;
check_typed_input(to, tk);
anon_send(message_priority::normal, actor_cast<channel>(to), anon_send(message_priority::normal, actor_cast<channel>(to),
std::forward<Ts>(vs)...); std::forward<Vs>(vs)...);
} }
/** /**
...@@ -173,7 +185,6 @@ inline void anon_send_tuple(const channel& to, message_priority prio, ...@@ -173,7 +185,6 @@ inline void anon_send_tuple(const channel& to, message_priority prio,
message msg) { message msg) {
send_as(invalid_actor, prio, to, std::move(msg)); send_as(invalid_actor, prio, to, std::move(msg));
} }
// </backward_compatibility> // </backward_compatibility>
} // namespace caf } // namespace caf
......
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