Commit be26b569 authored by ufownl's avatar ufownl

Add `extend_with` of `typed_actor`

parent 361dfa80
......@@ -30,6 +30,9 @@
namespace caf { // forward declarations
template <class... Ts>
class typed_actor;
template <class R>
class typed_continue_helper;
......@@ -267,6 +270,14 @@ struct sender_signature_checker<OrigSigs, DestSigs, detail::type_list<>> {
static void check() {}
};
template <class T, class... Ts>
struct extend_with_helper;
template <class... Ts, class... Es>
struct extend_with_helper<typed_actor<Es...>, Ts...> {
using type = typed_actor<Ts..., Es...>;
};
} // namespace detail
} // namespace caf
......
......@@ -76,6 +76,12 @@ class typed_actor : detail::comparable<typed_actor<Sigs...>>,
template <class... Es>
using extend = typed_actor<Sigs..., Es...>;
/// Creates a new `typed_actor` type by extending this one with another
/// `typed_actor`.
template <class T>
using extend_with =
typename detail::extend_with_helper<T, Sigs...>::type;
/// Identifies the behavior type actors of this kind use
/// for their behavior stack.
using behavior_type = typed_behavior<Sigs...>;
......
......@@ -48,6 +48,22 @@ static_assert(std::is_convertible<dummy2, dummy1>::value,
static_assert(! std::is_convertible<dummy1, dummy2>::value,
"handle is assignable to broader definition");
using dummy3 = typed_actor<reacts_to<float, int>>;
using dummy4 = typed_actor<replies_to<int>::with<double>>;
using dummy5 = dummy4::extend_with<dummy3>;
static_assert(std::is_convertible<dummy5, dummy3>::value,
"handle not assignable to narrower definition");
static_assert(std::is_convertible<dummy5, dummy4>::value,
"handle not assignable to narrower definition");
static_assert(! std::is_convertible<dummy3, dummy5>::value,
"handle is assignable to broader definition");
static_assert(! std::is_convertible<dummy4, dummy5>::value,
"handle is assignable to broader definition");
/******************************************************************************
* simple request/response test *
******************************************************************************/
......
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