Commit 8a5a1225 authored by Dominik Charousset's avatar Dominik Charousset

Fix `on(<atom constant>)`

parent f45693a0
...@@ -216,9 +216,18 @@ struct pattern_type_<false, T> { ...@@ -216,9 +216,18 @@ struct pattern_type_<false, T> {
}; };
template <class T> template <class T>
struct pattern_type struct pattern_type {
: pattern_type_< using type =
detail::is_callable<T>::value && !detail::is_boxed<T>::value, T> { }; typename pattern_type_<
detail::is_callable<T>::value && !detail::is_boxed<T>::value,
T
>::type;
};
template <atom_value V>
struct pattern_type<atom_constant<V>> {
using type = atom_value;
};
} // namespace detail } // namespace detail
} // namespace caf } // namespace caf
...@@ -302,11 +311,12 @@ constexpr boxed_arg_match_t arg_match = boxed_arg_match_t(); ...@@ -302,11 +311,12 @@ constexpr boxed_arg_match_t arg_match = boxed_arg_match_t();
template <class T, typename Predicate> template <class T, typename Predicate>
std::function<optional<T>(const T&)> guarded(Predicate p, T value) { std::function<optional<T>(const T&)> guarded(Predicate p, T value) {
return[=](const T & other)->optional<T> { return [=](const T& other)->optional<T> {
if (p(other, value)) return value; if (p(other, value)) {
return value;
}
return none; return none;
};
};
} }
// special case covering arg_match as argument to guarded() // special case covering arg_match as argument to guarded()
...@@ -344,6 +354,11 @@ F to_guard(F fun, ...@@ -344,6 +354,11 @@ F to_guard(F fun,
return fun; return fun;
} }
template <atom_value V>
auto to_guard(const atom_constant<V>&) -> decltype(to_guard(V)) {
return to_guard(V);
}
template <class T, class... Ts> template <class T, class... Ts>
auto on(const T& arg, const Ts&... args) auto on(const T& arg, const Ts&... args)
-> detail::rvalue_builder< -> detail::rvalue_builder<
......
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