Commit 01b91604 authored by neverlord's avatar neverlord

allow on_arg_match.when()

parent 1ca89acf
...@@ -247,42 +247,6 @@ struct pattern_type : pattern_type_<util::is_callable<T>::value && !detail::is_b ...@@ -247,42 +247,6 @@ struct pattern_type : pattern_type_<util::is_callable<T>::value && !detail::is_b
{ {
}; };
class on_the_fly_rvalue_builder
{
public:
constexpr on_the_fly_rvalue_builder()
{
}
template<typename Expr>
match_expr<
typename get_case<
false,
Expr,
value_guard< util::type_list<> >,
util::type_list<>,
util::type_list<>
>::type>
operator>>(Expr expr) const
{
typedef typename get_case<
false,
Expr,
value_guard< util::type_list<> >,
util::type_list<>,
util::type_list<>
>::type
result;
return result{typename result::first_type{},
typename result::second_type{
std::move(expr),
value_guard< util::type_list<> >{}}};
}
};
} } // cppa::detail } } // cppa::detail
...@@ -359,8 +323,6 @@ typedef typename detail::boxed<util::arg_match_t>::type boxed_arg_match_t; ...@@ -359,8 +323,6 @@ typedef typename detail::boxed<util::arg_match_t>::type boxed_arg_match_t;
constexpr boxed_arg_match_t arg_match = boxed_arg_match_t(); constexpr boxed_arg_match_t arg_match = boxed_arg_match_t();
constexpr detail::on_the_fly_rvalue_builder on_arg_match;
template<typename Arg0, typename... Args> template<typename Arg0, typename... Args>
detail::rvalue_builder< detail::rvalue_builder<
detail::value_guard< detail::value_guard<
...@@ -429,6 +391,56 @@ inline decltype(on<anything>()) others() ...@@ -429,6 +391,56 @@ inline decltype(on<anything>()) others()
return on<anything>(); return on<anything>();
} }
// some more convenience
namespace detail {
class on_the_fly_rvalue_builder
{
public:
constexpr on_the_fly_rvalue_builder()
{
}
template<typename Guard>
auto when(Guard g) const -> decltype(on(arg_match).when(g))
{
return on(arg_match).when(g);
}
template<typename Expr>
match_expr<
typename get_case<
false,
Expr,
value_guard< util::type_list<> >,
util::type_list<>,
util::type_list<>
>::type>
operator>>(Expr expr) const
{
typedef typename get_case<
false,
Expr,
value_guard< util::type_list<> >,
util::type_list<>,
util::type_list<>
>::type
result;
return result{typename result::first_type{},
typename result::second_type{
std::move(expr),
value_guard< util::type_list<> >{}}};
}
};
} // namespace detail
constexpr detail::on_the_fly_rvalue_builder on_arg_match;
#endif #endif
} // namespace cppa } // namespace cppa
......
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