Commit f9cad67e authored by Dominik Charousset's avatar Dominik Charousset

accept lvalue for or_else, fixes #93

parent dae0a89c
...@@ -133,7 +133,6 @@ class default_behavior_impl : public behavior_impl { ...@@ -133,7 +133,6 @@ class default_behavior_impl : public behavior_impl {
return new default_behavior_impl<MatchExpr,std::function<void()> >(m_expr, tdef); return new default_behavior_impl<MatchExpr,std::function<void()> >(m_expr, tdef);
} }
void handle_timeout() { m_fun(); } void handle_timeout() { m_fun(); }
private: private:
......
...@@ -107,7 +107,7 @@ class partial_function { ...@@ -107,7 +107,7 @@ class partial_function {
*/ */
template<typename... Ts> template<typename... Ts>
typename std::conditional< typename std::conditional<
util::disjunction<Ts::may_have_timeout...>::value, util::disjunction<util::rm_ref<Ts>::type::may_have_timeout...>::value,
behavior, behavior,
partial_function partial_function
>::type >::type
...@@ -163,7 +163,7 @@ inline bool partial_function::operator()(T&& arg) { ...@@ -163,7 +163,7 @@ inline bool partial_function::operator()(T&& arg) {
template<typename... Ts> template<typename... Ts>
typename std::conditional< typename std::conditional<
util::disjunction<Ts::may_have_timeout...>::value, util::disjunction<util::rm_ref<Ts>::type::may_have_timeout...>::value,
behavior, behavior,
partial_function partial_function
>::type >::type
......
...@@ -382,5 +382,19 @@ int main() { ...@@ -382,5 +382,19 @@ int main() {
bhvr_check(bhvr1, make_any_tuple(2.f), true, "<float>@2"); bhvr_check(bhvr1, make_any_tuple(2.f), true, "<float>@2");
bhvr_check(bhvr1, make_any_tuple(""), true, "<*>@4"); bhvr_check(bhvr1, make_any_tuple(""), true, "<*>@4");
partial_function pf11 {
on_arg_match >> [&](int) { last_invoked_fun = "<int>@1"; }
};
partial_function pf12 {
on_arg_match >> [&](int) { last_invoked_fun = "<int>@2"; },
on_arg_match >> [&](float) { last_invoked_fun = "<float>@2"; }
};
auto pf13 = pf11.or_else(pf12);
bhvr_check(pf13, make_any_tuple(42), true, "<int>@1");
bhvr_check(pf13, make_any_tuple(42.24f), true, "<float>@2");
return CPPA_TEST_RESULT(); return CPPA_TEST_RESULT();
} }
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