Commit cf13709e authored by neverlord's avatar neverlord

refactoring (gbind -> gcall)

parent 332f9eee
...@@ -116,19 +116,19 @@ struct guard_expr ...@@ -116,19 +116,19 @@ struct guard_expr
// bind utility for placeholders // bind utility for placeholders
template<typename Fun, typename T1> template<typename Fun, typename T1>
struct gbind1 struct gcall1
{ {
typedef guard_expr<exec_fun1_op, Fun, T1> result; typedef guard_expr<exec_fun1_op, Fun, T1> result;
}; };
template<typename Fun, typename T1, typename T2> template<typename Fun, typename T1, typename T2>
struct gbind2 struct gcall2
{ {
typedef guard_expr<exec_fun2_op, guard_expr<dummy_op, Fun, T1>, T2> result; typedef guard_expr<exec_fun2_op, guard_expr<dummy_op, Fun, T1>, T2> result;
}; };
template<typename Fun, typename T1, typename T2, typename T3> template<typename Fun, typename T1, typename T2, typename T3>
struct gbind3 struct gcall3
{ {
typedef guard_expr<exec_fun3_op, guard_expr<dummy_op, Fun, T1>, typedef guard_expr<exec_fun3_op, guard_expr<dummy_op, Fun, T1>,
guard_expr<dummy_op, T2, T3> > guard_expr<dummy_op, T2, T3> >
...@@ -139,7 +139,7 @@ struct gbind3 ...@@ -139,7 +139,7 @@ struct gbind3
* @brief Call wrapper for guard placeholders and lazy evaluation. * @brief Call wrapper for guard placeholders and lazy evaluation.
*/ */
template<typename Fun, typename T1> template<typename Fun, typename T1>
typename gbind1<Fun, T1>::result gbind(Fun fun, T1 t1) typename gcall1<Fun, T1>::result gcall(Fun fun, T1 t1)
{ {
return {fun, t1}; return {fun, t1};
} }
...@@ -148,7 +148,7 @@ typename gbind1<Fun, T1>::result gbind(Fun fun, T1 t1) ...@@ -148,7 +148,7 @@ typename gbind1<Fun, T1>::result gbind(Fun fun, T1 t1)
* @brief Call wrapper for guard placeholders and lazy evaluation. * @brief Call wrapper for guard placeholders and lazy evaluation.
*/ */
template<typename Fun, typename T1, typename T2> template<typename Fun, typename T1, typename T2>
typename gbind2<Fun, T1, T2>::result gbind(Fun fun, T1 t1, T2 t2) typename gcall2<Fun, T1, T2>::result gcall(Fun fun, T1 t1, T2 t2)
{ {
return {fun, t1, t2}; return {fun, t1, t2};
} }
...@@ -157,16 +157,17 @@ typename gbind2<Fun, T1, T2>::result gbind(Fun fun, T1 t1, T2 t2) ...@@ -157,16 +157,17 @@ typename gbind2<Fun, T1, T2>::result gbind(Fun fun, T1 t1, T2 t2)
* @brief Call wrapper for guard placeholders and lazy evaluation. * @brief Call wrapper for guard placeholders and lazy evaluation.
*/ */
template<typename Fun, typename T1, typename T2, typename T3> template<typename Fun, typename T1, typename T2, typename T3>
typename gbind3<Fun, T1, T2, T3>::result gbind(Fun fun, T1 t1, T2 t2, T3 t3) typename gcall3<Fun, T1, T2, T3>::result gcall(Fun fun, T1 t1, T2 t2, T3 t3)
{ {
return {fun, t1, t2, t3}; return {fun, t1, t2, t3};
} }
/** /**
* @brief Call wrapper for any given functor returning a boolean. * @brief Calls @p fun with all arguments given to the guard expression.
* The functor @p fun must return a boolean.
*/ */
template<typename Fun> template<typename Fun>
guard_expr<exec_xfun_op, Fun, util::void_type> gcall(Fun fun) guard_expr<exec_xfun_op, Fun, util::void_type> ge_sub_function(Fun fun)
{ {
return {fun, util::void_type{}}; return {fun, util::void_type{}};
} }
...@@ -205,12 +206,12 @@ struct guard_placeholder ...@@ -205,12 +206,12 @@ struct guard_placeholder
constexpr guard_placeholder() { } constexpr guard_placeholder() { }
/** /**
* @brief Convenient way to call <tt>gbind(fun, guard_placeholder)</tt>. * @brief Convenient way to call <tt>gcall(fun, guard_placeholder)</tt>.
*/ */
template<typename Fun> template<typename Fun>
typename gbind1<Fun, guard_placeholder>::result operator()(Fun fun) const typename gcall1<Fun, guard_placeholder>::result operator()(Fun fun) const
{ {
return gbind(fun, *this); return gcall(fun, *this);
} }
// utility function for starts_with() // utility function for starts_with()
...@@ -222,13 +223,13 @@ struct guard_placeholder ...@@ -222,13 +223,13 @@ struct guard_placeholder
/** /**
* @brief Evaluates to true if unbound argument starts with @p str. * @brief Evaluates to true if unbound argument starts with @p str.
*/ */
typename gbind2<decltype(&guard_placeholder::u8_starts_with), typename gcall2<decltype(&guard_placeholder::u8_starts_with),
guard_placeholder, guard_placeholder,
std::string std::string
>::result >::result
starts_with(std::string str) const starts_with(std::string str) const
{ {
return gbind(&guard_placeholder::u8_starts_with, *this, str); return gcall(&guard_placeholder::u8_starts_with, *this, str);
} }
/** /**
...@@ -236,10 +237,10 @@ struct guard_placeholder ...@@ -236,10 +237,10 @@ struct guard_placeholder
* is contained in @p container. * is contained in @p container.
*/ */
template<class C> template<class C>
typename gbind2<ge_search_container, C, guard_placeholder>::result typename gcall2<ge_search_container, C, guard_placeholder>::result
in(C container) const in(C container) const
{ {
return gbind(ge_search_container{true}, container, *this); return gcall(ge_search_container{true}, container, *this);
} }
/** /**
...@@ -247,13 +248,13 @@ struct guard_placeholder ...@@ -247,13 +248,13 @@ struct guard_placeholder
* is contained in @p container. * is contained in @p container.
*/ */
template<class C> template<class C>
typename gbind2<ge_search_container, typename gcall2<ge_search_container,
std::reference_wrapper<C>, std::reference_wrapper<C>,
guard_placeholder guard_placeholder
>::result >::result
in(std::reference_wrapper<C> container) const in(std::reference_wrapper<C> container) const
{ {
return gbind(ge_search_container{true}, container, *this); return gcall(ge_search_container{true}, container, *this);
} }
/** /**
...@@ -261,7 +262,7 @@ struct guard_placeholder ...@@ -261,7 +262,7 @@ struct guard_placeholder
* is contained in @p list. * is contained in @p list.
*/ */
template<typename T> template<typename T>
typename gbind2<ge_search_container, typename gcall2<ge_search_container,
std::vector<typename detail::strip_and_convert<T>::type>, std::vector<typename detail::strip_and_convert<T>::type>,
guard_placeholder guard_placeholder
>::result >::result
...@@ -277,10 +278,10 @@ struct guard_placeholder ...@@ -277,10 +278,10 @@ struct guard_placeholder
* is not contained in @p container. * is not contained in @p container.
*/ */
template<class C> template<class C>
typename gbind2<ge_search_container, C, guard_placeholder>::result typename gcall2<ge_search_container, C, guard_placeholder>::result
not_in(C container) const not_in(C container) const
{ {
return gbind(ge_search_container{false}, container, *this); return gcall(ge_search_container{false}, container, *this);
} }
/** /**
...@@ -288,13 +289,13 @@ struct guard_placeholder ...@@ -288,13 +289,13 @@ struct guard_placeholder
* is not contained in @p container. * is not contained in @p container.
*/ */
template<class C> template<class C>
typename gbind2<ge_search_container, typename gcall2<ge_search_container,
std::reference_wrapper<C>, std::reference_wrapper<C>,
guard_placeholder guard_placeholder
>::result >::result
not_in(std::reference_wrapper<C> container) const not_in(std::reference_wrapper<C> container) const
{ {
return gbind(ge_search_container{false}, container, *this); return gcall(ge_search_container{false}, container, *this);
} }
/** /**
...@@ -302,7 +303,7 @@ struct guard_placeholder ...@@ -302,7 +303,7 @@ struct guard_placeholder
* is not contained in @p list. * is not contained in @p list.
*/ */
template<typename T> template<typename T>
typename gbind2<ge_search_container, typename gcall2<ge_search_container,
std::vector<typename detail::strip_and_convert<T>::type>, std::vector<typename detail::strip_and_convert<T>::type>,
guard_placeholder guard_placeholder
>::result >::result
......
...@@ -160,7 +160,7 @@ struct rvalue_builder ...@@ -160,7 +160,7 @@ struct rvalue_builder
&& !std::is_same<Guard, value_guard< util::type_list<> >>::value && !std::is_same<Guard, value_guard< util::type_list<> >>::value
>::type* = 0 ) const >::type* = 0 ) const
{ {
return {(gcall(m_guard) && ng), std::move(m_funs)}; return {(ge_sub_function(m_guard) && ng), std::move(m_funs)};
} }
template<typename NewGuard> template<typename NewGuard>
......
...@@ -34,12 +34,12 @@ size_t test__match() ...@@ -34,12 +34,12 @@ size_t test__match()
using namespace std::placeholders; using namespace std::placeholders;
using namespace cppa::placeholders; using namespace cppa::placeholders;
auto expr0 = gbind(ascending, _x1, _x2, _x3); auto expr0 = gcall(ascending, _x1, _x2, _x3);
CPPA_CHECK(ge_invoke(expr0, 1, 2, 3)); CPPA_CHECK(ge_invoke(expr0, 1, 2, 3));
CPPA_CHECK(!ge_invoke(expr0, 3, 2, 1)); CPPA_CHECK(!ge_invoke(expr0, 3, 2, 1));
int ival0 = 2; int ival0 = 2;
auto expr01 = gbind(ascending, _x1, std::ref(ival0), _x2); auto expr01 = gcall(ascending, _x1, std::ref(ival0), _x2);
CPPA_CHECK(ge_invoke(expr01, 1, 3)); CPPA_CHECK(ge_invoke(expr01, 1, 3));
++ival0; ++ival0;
CPPA_CHECK(!ge_invoke(expr01, 1, 3)); CPPA_CHECK(!ge_invoke(expr01, 1, 3));
......
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