Commit 1191e362 authored by Dominik Charousset's avatar Dominik Charousset

Fix conversion of scoped_actor on older compilers

parent 468fe088
......@@ -49,12 +49,15 @@ constexpr invalid_actor_t invalid_actor = invalid_actor_t{};
template <class T>
struct is_convertible_to_actor {
using type = typename std::remove_pointer<T>::type;
static constexpr bool value =
! std::is_base_of<statically_typed_actor_base, type>::value
&& (std::is_base_of<actor_proxy, type>::value
|| std::is_base_of<local_actor, type>::value
|| std::is_same<scoped_actor, type>::value);
! std::is_base_of<statically_typed_actor_base, T>::value
&& (std::is_base_of<actor_proxy, T>::value
|| std::is_base_of<local_actor, T>::value);
};
template <>
struct is_convertible_to_actor<scoped_actor> : std::true_type {
// nop
};
/// Identifies an untyped actor. Can be used with derived types
......@@ -95,6 +98,7 @@ public:
// nop
}
actor(const scoped_actor&);
actor(const invalid_actor_t&);
template <class T>
......@@ -113,6 +117,7 @@ public:
return *this;
}
actor& operator=(const scoped_actor& x);
actor& operator=(const invalid_actor_t&);
/// Returns the address of the stored actor.
......
......@@ -59,6 +59,7 @@ public:
channel(const actor&);
channel(const group&);
channel(const scoped_actor&);
channel(const invalid_channel_t&);
template <class T>
......@@ -75,6 +76,7 @@ public:
channel& operator=(const actor&);
channel& operator=(const group&);
channel& operator=(const scoped_actor&);
channel& operator=(const invalid_channel_t&);
inline explicit operator bool() const noexcept {
......
......@@ -21,10 +21,9 @@
#define CAF_DETAIL_SPAWN_FWD_HPP
#include <functional>
#include <type_traits>
#include "caf/fwd.hpp"
#include "caf/detail/type_traits.hpp"
#include "caf/actor.hpp"
namespace caf {
namespace detail {
......
......@@ -20,10 +20,8 @@
#ifndef CAF_SCOPED_ACTOR_HPP
#define CAF_SCOPED_ACTOR_HPP
#include "caf/actor.hpp"
#include "caf/channel.hpp"
#include "caf/behavior.hpp"
#include "caf/actor_cast.hpp"
#include "caf/actor_system.hpp"
#include "caf/intrusive_ptr.hpp"
#include "caf/blocking_actor.hpp"
#include "caf/scoped_execution_unit.hpp"
......@@ -53,18 +51,6 @@ public:
return self_.get();
}
inline operator channel() const {
return actor_cast<channel>(self_);
}
inline operator actor() const {
return actor_cast<actor>(self_);
}
inline operator actor_addr() const {
return self_->address();
}
inline actor_addr address() const {
return self_->address();
}
......
......@@ -27,6 +27,7 @@
#include "caf/actor_proxy.hpp"
#include "caf/local_actor.hpp"
#include "caf/deserializer.hpp"
#include "caf/scoped_actor.hpp"
#include "caf/blocking_actor.hpp"
#include "caf/event_based_actor.hpp"
......@@ -36,6 +37,10 @@
namespace caf {
actor::actor(const scoped_actor& x) : ptr_(x.get()) {
// nop
}
actor::actor(const invalid_actor_t&) : ptr_(nullptr) {
// nop
}
......@@ -48,6 +53,11 @@ actor::actor(abstract_actor* ptr, bool add_ref) : ptr_(ptr, add_ref) {
// nop
}
actor& actor::operator=(const scoped_actor& x) {
ptr_.reset(x.get());
return *this;
}
actor& actor::operator=(const invalid_actor_t&) {
ptr_.reset();
return *this;
......
......@@ -26,17 +26,28 @@
#include "caf/actor_cast.hpp"
#include "caf/local_actor.hpp"
#include "caf/actor_system.hpp"
#include "caf/scoped_actor.hpp"
#include "caf/abstract_actor.hpp"
#include "caf/abstract_group.hpp"
#include "caf/proxy_registry.hpp"
namespace caf {
channel::channel(const actor& x) : ptr_(actor_cast<abstract_channel*>(x)) {
namespace {
using ch_pointer = abstract_channel*;
} // namespace <anonymous>
channel::channel(const actor& x) : ptr_(actor_cast<ch_pointer>(x)) {
// nop
}
channel::channel(const group& x) : ptr_(actor_cast<abstract_channel*>(x)) {
channel::channel(const group& x) : ptr_(actor_cast<ch_pointer>(x)) {
// nop
}
channel::channel(const scoped_actor& x) : ptr_(actor_cast<ch_pointer>(x)) {
// nop
}
......@@ -58,12 +69,17 @@ channel::channel(local_actor* ptr) : ptr_(ptr) {
}
channel& channel::operator=(const actor& x) {
ptr_.reset(actor_cast<abstract_channel*>(x));
ptr_.reset(actor_cast<ch_pointer>(x));
return *this;
}
channel& channel::operator=(const group& x) {
ptr_.reset(actor_cast<abstract_channel*>(x));
ptr_.reset(actor_cast<ch_pointer>(x));
return *this;
}
channel& channel::operator=(const scoped_actor& x) {
ptr_.reset(actor_cast<ch_pointer>(x));
return *this;
}
......
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