Commit 5c0525b7 authored by Joseph Noir's avatar Joseph Noir

Merge branch 'topic/announce_optionals' into develop

parents 0a86b71c 2b4734b9
......@@ -479,6 +479,16 @@ struct type_at<0, T0, Ts...> {
using type = T0;
};
template <class T>
struct is_optional : std::false_type {
// no members
};
template <class T>
struct is_optional<optional<T>> : std::true_type {
// no members
};
} // namespace detail
} // namespace caf
......
......@@ -335,19 +335,13 @@ struct to_guard<anything, false> {
template <class T>
struct to_guard<detail::wrapped<T>, false> : to_guard<anything> {};
template <class T>
struct is_optional : std::false_type {};
template <class T>
struct is_optional<optional<T>> : std::true_type {};
template <class T>
struct to_guard<T, true> {
using ct = typename detail::get_callable_trait<T>::type;
using arg_types = typename ct::arg_types;
static_assert(detail::tl_size<arg_types>::value == 1,
"projection/guard must take exactly one argument");
static_assert(is_optional<typename ct::result_type>::value,
static_assert(detail::is_optional<typename ct::result_type>::value,
"projection/guard must return an optional value");
using value_type =
typename std::conditional<
......@@ -355,8 +349,9 @@ struct to_guard<T, true> {
T*,
T
>::type;
static value_type _(value_type val) { return val; }
static value_type _(value_type val) {
return val;
}
};
template <class T>
......
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