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