Commit e43e9bf6 authored by Dominik Charousset's avatar Dominik Charousset

maintenance

parent c11d8467
......@@ -130,7 +130,7 @@ struct ebaf_from_functor {
static_assert(util::tl_forall<arg_types, std::is_pointer>::value,
"First functor takes non-pointer arguments");
static_assert( std::is_same<arg_types, arg_types2>::value
|| std::is_same<util::type_list<>, arg_types2>::value,
|| util::tl_empty<arg_types2>::value,
"Second functor must provide either the same signature "
"as the first one or must take zero arguments");
typedef typename util::tl_map<arg_types, std::remove_pointer>::type mems;
......
......@@ -146,7 +146,7 @@ class projection {
};
template<>
class projection<util::type_list<> > {
class projection<util::empty_type_list> {
public:
......
......@@ -51,7 +51,7 @@ struct serialize_tuple {
};
template<size_t Pos>
struct serialize_tuple<util::type_list<>, Pos> {
struct serialize_tuple<util::empty_type_list, Pos> {
template<typename T>
inline static void _(serializer&, const T*) { }
};
......
......@@ -129,7 +129,7 @@ struct tdata<> {
typedef util::void_type head_type;
typedef tdata<> tail_type;
typedef util::void_type back_type;
typedef util::type_list<> types;
typedef util::empty_type_list types;
static constexpr size_t num_elements = 0;
......
......@@ -129,6 +129,8 @@ class value_guard {
};
typedef value_guard<util::empty_type_list> empty_value_guard;
} } // namespace cppa::detail
#endif // CPPA_VALUE_GUARD_HPP
......@@ -207,7 +207,7 @@ struct invoke_policy_impl<wildcard_position::nil,
template<>
struct invoke_policy_impl<wildcard_position::leading,
util::type_list<anything>,
util::type_list<> > {
util::empty_type_list> {
template<class Tuple>
static inline bool can_invoke(const std::type_info&,
const Tuple&) {
......@@ -451,20 +451,6 @@ struct get_case<false, Expr, Guard, Transformers, Pattern> {
type;
};
/*
template<class Expr>
struct get_case<true, Expr, value_guard<util::type_list<> >,
util::type_list<>, util::type_list<anything> > {
typedef typename get_case_<
Expr,
value_guard<util::type_list<> >,
util::type_list<>,
util::type_list<anything>
>::type
type;
};
*/
template<typename First, typename Second>
struct pjf_same_pattern
: std::is_same<typename First::second::pattern_type,
......
......@@ -58,65 +58,54 @@
namespace cppa { namespace detail {
template<bool IsFun, typename T>
struct add_ptr_to_fun_ {
typedef T* type;
};
struct add_ptr_to_fun_ { typedef T* type; };
template<typename T>
struct add_ptr_to_fun_<false, T> {
typedef T type;
};
struct add_ptr_to_fun_<false, T> { typedef T type; };
template<typename T>
struct add_ptr_to_fun : add_ptr_to_fun_<std::is_function<T>::value, T> {
};
struct add_ptr_to_fun : add_ptr_to_fun_<std::is_function<T>::value, T> { };
template<bool ToVoid, typename T>
struct to_void_impl {
typedef util::void_type type;
};
struct to_void_impl { typedef util::void_type type; };
template<typename T>
struct to_void_impl<false, T> {
typedef typename add_ptr_to_fun<T>::type type;
};
struct to_void_impl<false,T> { typedef typename add_ptr_to_fun<T>::type type; };
template<typename T>
struct not_callable_to_void : to_void_impl<detail::is_boxed<T>::value || !util::is_callable<T>::value, T> {
};
struct boxed_and_not_callable_to_void
: to_void_impl<is_boxed<T>::value || !util::is_callable<T>::value, T> { };
template<typename T>
struct boxed_and_callable_to_void : to_void_impl<detail::is_boxed<T>::value || util::is_callable<T>::value, T> {
};
struct boxed_and_callable_to_void
: to_void_impl<is_boxed<T>::value || util::is_callable<T>::value, T> { };
class behavior_rvalue_builder {
util::duration m_timeout;
public:
constexpr behavior_rvalue_builder(const util::duration& d) : m_timeout(d) {
}
constexpr behavior_rvalue_builder(const util::duration& d) : m_tout(d) { }
template<typename F>
timeout_definition<F> operator>>(F&& f) {
return {m_timeout, std::forward<F>(f)};
timeout_definition<F> operator>>(F&& f) const {
return {m_tout, std::forward<F>(f)};
}
private:
util::duration m_tout;
};
struct rvalue_builder_args_ctor { };
template<class Left, class Right>
struct disjunct_rvalue_builders {
Left m_left;
Right m_right;
public:
disjunct_rvalue_builders(Left l, Right r) : m_left(std::move(l))
, m_right(std::move(r)) {
}
disjunct_rvalue_builders(Left l, Right r)
: m_left(std::move(l)), m_right(std::move(r)) { }
template<typename Expr>
auto operator>>(Expr expr)
......@@ -125,6 +114,11 @@ struct disjunct_rvalue_builders {
return (m_left >> expr).or_else(m_right >> expr);
}
private:
Left m_left;
Right m_right;
};
template<class Guard, class Transformers, class Pattern>
......@@ -163,7 +157,7 @@ struct rvalue_builder {
when(NewGuard ng,
typename std::enable_if<
std::is_same<NewGuard, NewGuard>::value
&& !std::is_same<Guard, value_guard< util::type_list<> >>::value
&& !std::is_same<Guard, empty_value_guard>::value
>::type* = 0 ) const {
return {(ge_sub_function(m_guard) && ng), std::move(m_funs)};
}
......@@ -173,8 +167,8 @@ struct rvalue_builder {
when(NewGuard ng,
typename std::enable_if<
std::is_same<NewGuard, NewGuard>::value
&& std::is_same<Guard, value_guard< util::type_list<> >>::value
>::type* = 0 ) const {
&& std::is_same<Guard, empty_value_guard>::value
>::type* = 0 ) const {
return {std::move(ng), std::move(m_funs)};
}
......@@ -311,7 +305,7 @@ detail::rvalue_builder<
>,
typename util::tl_map<
util::type_list<Arg0, Args...>,
detail::not_callable_to_void
detail::boxed_and_not_callable_to_void
>::type,
util::type_list<typename detail::pattern_type<Arg0>::type,
typename detail::pattern_type<Args>::type...> >
......@@ -320,9 +314,9 @@ on(const Arg0& arg0, const Args&... args) {
}
template<typename... T>
detail::rvalue_builder<detail::value_guard<util::type_list<> >,
util::type_list<>,
util::type_list<T...> >
detail::rvalue_builder<detail::empty_value_guard,
util::empty_type_list,
util::type_list<T...> >
on() {
return {};
}
......@@ -366,8 +360,7 @@ class on_the_fly_rvalue_builder {
public:
constexpr on_the_fly_rvalue_builder() {
}
constexpr on_the_fly_rvalue_builder() { }
template<typename Guard>
auto when(Guard g) const -> decltype(on(arg_match).when(g)) {
......@@ -379,23 +372,23 @@ class on_the_fly_rvalue_builder {
typename get_case<
false,
Expr,
value_guard< util::type_list<> >,
util::type_list<>,
util::type_list<>
empty_value_guard,
util::empty_type_list,
util::empty_type_list
>::type>
operator>>(Expr expr) const {
typedef typename get_case<
false,
Expr,
value_guard< util::type_list<> >,
util::type_list<>,
util::type_list<>
empty_value_guard,
util::empty_type_list,
util::empty_type_list
>::type
result;
return result{typename result::first_type{},
typename result::second_type{
std::move(expr),
value_guard< util::type_list<> >{}}};
result_type;
return result_type{typename result_type::first_type{},
typename result_type::second_type{
std::move(expr),
empty_value_guard{}}};
}
};
......
......@@ -87,6 +87,8 @@ struct type_list<Head, Tail...> {
};
typedef type_list<> empty_type_list;
template<typename T>
struct is_type_list {
static constexpr bool value = false;
......@@ -97,6 +99,16 @@ struct is_type_list<type_list<Ts...> > {
static constexpr bool value = true;
};
// bool empty(type_list)
/**
* @brief Tests whether a list is empty.
*/
template<class List>
struct tl_empty {
static constexpr bool value = std::is_same<empty_type_list, List>::value;
};
// list slice(size_t, size_t)
template<size_t LeftOffset, size_t Remaining,
......@@ -125,12 +137,12 @@ struct tl_slice_impl<0, Remaining, PadType, List, T...> {
};
template<size_t Remaining, typename PadType, typename... T>
struct tl_slice_impl<0, Remaining, PadType, type_list<>, T...> {
struct tl_slice_impl<0, Remaining, PadType, empty_type_list, T...> {
typedef typename tl_slice_impl<
0,
Remaining - 1,
PadType,
type_list<>,
empty_type_list,
T..., PadType
>::type
type;
......@@ -142,7 +154,7 @@ struct tl_slice_impl<0, 0, PadType, List, T...> {
};
template<typename PadType, typename... T>
struct tl_slice_impl<0, 0, PadType, type_list<>, T...> {
struct tl_slice_impl<0, 0, PadType, empty_type_list, T...> {
typedef type_list<T...> type;
};
......@@ -263,8 +275,8 @@ struct tl_zip_with_index {
};
template<>
struct tl_zip_with_index<type_list<> > {
typedef type_list<> type;
struct tl_zip_with_index<empty_type_list> {
typedef empty_type_list type;
};
// list reverse()
......@@ -278,7 +290,7 @@ struct tl_reverse_impl<type_list<T0, T...>, E...> {
};
template<typename... E>
struct tl_reverse_impl<type_list<>, E...> {
struct tl_reverse_impl<empty_type_list, E...> {
typedef type_list<E...> type;
};
......@@ -300,7 +312,7 @@ template<class List, template<typename> class Predicate, int Pos = 0>
struct tl_find_impl;
template<template<typename> class Predicate, int Pos>
struct tl_find_impl<type_list<>, Predicate, Pos> {
struct tl_find_impl<empty_type_list, Predicate, Pos> {
static constexpr int value = -1;
};
......@@ -348,7 +360,7 @@ struct tl_forall {
};
template<template<typename> class Predicate>
struct tl_forall<type_list<>, Predicate> {
struct tl_forall<empty_type_list, Predicate> {
static constexpr bool value = true;
};
......@@ -364,7 +376,7 @@ struct tl_forall2_impl {
};
template<template<typename, typename> class Predicate>
struct tl_forall2_impl<type_list<>, type_list<>, Predicate> {
struct tl_forall2_impl<empty_type_list, empty_type_list, Predicate> {
static constexpr bool value = true;
};
......@@ -390,7 +402,7 @@ struct tl_exists {
};
template<template<typename> class Predicate>
struct tl_exists<type_list<>, Predicate> {
struct tl_exists<empty_type_list, Predicate> {
static constexpr bool value = false;
};
......@@ -407,7 +419,7 @@ struct tl_count {
};
template<template<typename> class Predicate>
struct tl_count<type_list<>, Predicate> {
struct tl_count<empty_type_list, Predicate> {
static constexpr size_t value = 0;
};
......@@ -423,7 +435,7 @@ struct tl_count_not {
};
template<template<typename> class Predicate>
struct tl_count_not<type_list<>, Predicate> {
struct tl_count_not<empty_type_list, Predicate> {
static constexpr size_t value = 0;
};
......@@ -441,7 +453,7 @@ struct tl_zipped_forall {
};
template<template<typename, typename> class Predicate>
struct tl_zipped_forall<type_list<>, Predicate> {
struct tl_zipped_forall<empty_type_list, Predicate> {
static constexpr bool value = true;
};
......@@ -561,8 +573,8 @@ struct tl_map_conditional {
template<template<typename> class Trait,
bool TraitResult,
template<typename> class... Funs>
struct tl_map_conditional<type_list<>, Trait, TraitResult, Funs...> {
typedef type_list<> type;
struct tl_map_conditional<empty_type_list, Trait, TraitResult, Funs...> {
typedef empty_type_list type;
};
/*
......@@ -611,8 +623,8 @@ struct tl_pop_back {
};
template<>
struct tl_pop_back<type_list<> > {
typedef type_list<> type;
struct tl_pop_back<empty_type_list> {
typedef empty_type_list type;
};
// type at(size_t)
......@@ -664,8 +676,8 @@ template<class List, bool... Selected>
struct tl_filter_impl;
template<>
struct tl_filter_impl< type_list<> > {
typedef type_list<> type;
struct tl_filter_impl<empty_type_list> {
typedef empty_type_list type;
};
template<typename T0, typename... T, bool... S>
......@@ -697,8 +709,8 @@ template<class List, template<typename> class Predicate>
struct tl_filter_not;
template<template<typename> class Predicate>
struct tl_filter_not<type_list<>, Predicate> {
typedef type_list<> type;
struct tl_filter_not<empty_type_list, Predicate> {
typedef empty_type_list type;
};
template<template<typename> class Predicate, typename... T>
......@@ -739,7 +751,7 @@ template<class List>
struct tl_distinct;
template<>
struct tl_distinct<type_list<> > { typedef type_list<> type; };
struct tl_distinct<empty_type_list> { typedef empty_type_list type; };
template<typename Head, typename... Tail>
struct tl_distinct<type_list<Head, Tail...> > {
......@@ -845,8 +857,8 @@ struct tl_trim {
};
template<typename What>
struct tl_trim<type_list<>, What> {
typedef type_list<> type;
struct tl_trim<empty_type_list, What> {
typedef empty_type_list type;
};
// list group_by(list, predicate)
......@@ -885,7 +897,7 @@ struct tl_group_by_impl {
};
template<template<typename, typename> class Predicate, typename Head, typename... Tail>
struct tl_group_by_impl<type_list<Head, Tail...>, type_list<>, Predicate> {
struct tl_group_by_impl<type_list<Head, Tail...>, empty_type_list, Predicate> {
typedef typename tl_group_by_impl<
type_list<Tail...>,
type_list<type_list<Head> >,
......@@ -895,14 +907,14 @@ struct tl_group_by_impl<type_list<Head, Tail...>, type_list<>, Predicate> {
};
template<class Out, template<typename, typename> class Predicate>
struct tl_group_by_impl<type_list<>, Out, Predicate> {
struct tl_group_by_impl<empty_type_list, Out, Predicate> {
typedef Out type;
};
template<class List, template<typename, typename> class Predicate>
struct tl_group_by {
typedef typename tl_group_by_impl<List, type_list<>, Predicate>::type type;
typedef typename tl_group_by_impl<List, empty_type_list, Predicate>::type type;
};
/**
......
......@@ -61,7 +61,7 @@ bool empty_tuple::equals(const abstract_tuple& other) const {
}
const std::type_info* empty_tuple::type_token() const {
return &typeid(util::type_list<>);
return &typeid(util::empty_type_list);
}
} } // namespace cppa::detail
......@@ -27,12 +27,16 @@ bool ascending(int a, int b, int c) {
return a < b && b < c;
}
vector<const uniform_type_info*> to_vec(util::type_list<>, vector<const uniform_type_info*> vec = vector<const uniform_type_info*>{}) {
vector<const uniform_type_info*>
to_vec(util::empty_type_list,
vector<const uniform_type_info*> vec=vector<const uniform_type_info*>{}){
return vec;
}
template<typename Head, typename... Tail>
vector<const uniform_type_info*> to_vec(util::type_list<Head, Tail...>, vector<const uniform_type_info*> vec = vector<const uniform_type_info*>{}) {
vector<const uniform_type_info*>
to_vec(util::type_list<Head, Tail...>,
vector<const uniform_type_info*> vec=vector<const uniform_type_info*>{}){
vec.push_back(uniform_typeid<Head>());
return to_vec(util::type_list<Tail...>{}, std::move(vec));
}
......@@ -106,22 +110,6 @@ size_t test__match() {
using namespace std::placeholders;
using namespace cppa::placeholders;
/*
auto x_ = get__([](int, float) { cout << "yeeeehaaaa!" << endl; })["prints 'yeeeehaaaa'"];
cout << "x_: "; x_(1, 1.f);
cout << "x_.annotation() = " << x_.annotation() << endl;
cout << "x_.plot_signature: "; x_.plot_signature();
auto fun = (
on<int>() >> [](int i) {
cout << "i = " << i << endl;
},
after(std::chrono::seconds(0)) >> []() {
cout << "no int found in mailbox" << endl;
}
);
*/
auto expr0_a = gcall(ascending, _x1, _x2, _x3);
CPPA_CHECK(ge_invoke(expr0_a, 1, 2, 3));
CPPA_CHECK(!ge_invoke(expr0_a, 3, 2, 1));
......
......@@ -595,6 +595,16 @@ size_t test__spawn() {
a2 << kill_msg;
await_all_others_done();
factory::event_based([](int* i) {
self->become(
after(std::chrono::milliseconds(50)) >> [=]() {
if (++(*i) >= 5) self->quit();
}
);
}).spawn();
await_all_others_done();
auto res1 = behavior_test<testee_actor>(spawn(testee_actor{}));
CPPA_CHECK_EQUAL(res1, "wait4int");
CPPA_CHECK_EQUAL(behavior_test<event_testee>(spawn<event_testee>()), "wait4int");
......
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