Commit ff1724f7 authored by neverlord's avatar neverlord

Merge branch 'master' of github.com:Neverlord/libcppa

parents aa0427cb 68fe080c
...@@ -225,21 +225,17 @@ bool matches(std::integral_constant<int, 0>, ...@@ -225,21 +225,17 @@ bool matches(std::integral_constant<int, 0>,
typedef typename decorated_tuple_from_type_list<ptypes>::type dec_t; typedef typename decorated_tuple_from_type_list<ptypes>::type dec_t;
typedef typename tuple_vals_from_type_list<ptypes>::type tv_t; typedef typename tuple_vals_from_type_list<ptypes>::type tv_t;
std::type_info const& tinfo = tpl.impl_type(); std::type_info const& tinfo = tpl.impl_type();
auto j = pttrn.begin();
auto end = tpl.end();
if (tinfo == typeid(dec_t) || tinfo == typeid(tv_t)) if (tinfo == typeid(dec_t) || tinfo == typeid(tv_t))
{ {
if (pttrn.has_values()) if (pttrn.has_values())
{ {
// compare values only (types are guaranteed to be equal) // compare values only (types are guaranteed to be equal)
auto eq = [](type_value_pair const& lhs, type_value_pair const& rhs) for (auto i = tpl.begin(); i != end; ++i, ++j)
{ {
// pattern (rhs) does not have to have a value if ( j->second != nullptr
return rhs.second == nullptr && i->first->equals(i->second, j->second) == false) return false;
|| lhs.first->equals(lhs.second, rhs.second);
};
if (std::equal(tpl.begin(), tpl.end(), pttrn.begin(), eq) == false)
{
// values differ
return false;
} }
} }
} }
...@@ -248,30 +244,19 @@ bool matches(std::integral_constant<int, 0>, ...@@ -248,30 +244,19 @@ bool matches(std::integral_constant<int, 0>,
if (pttrn.has_values()) if (pttrn.has_values())
{ {
// compares type and value // compares type and value
auto eq = [](type_value_pair const& lhs, type_value_pair const& rhs) for (auto i = tpl.begin(); i != end; ++i, ++j)
{
// pattern (rhs) does not have to have a value
return lhs.first == rhs.first
&& ( rhs.second == nullptr
|| lhs.first->equals(lhs.second, rhs.second));
};
if (std::equal(tpl.begin(), tpl.end(), pttrn.begin(), eq) == false)
{ {
// types or values differ if ( i->first != j->first
return false; || ( j->second != nullptr
&& i->first->equals(i->second, j->second) == false)) return false;
} }
} }
else else
{ {
// compares the types only // compares the types only
auto eq = [](type_value_pair const& lhs, type_value_pair const& rhs) for (auto i = tpl.begin(); i != end; ++i, ++j)
{
return lhs.first == rhs.first;
};
if (std::equal(tpl.begin(), tpl.end(), pttrn.begin(), eq) == false)
{ {
// types differ if (i->first != j->first) return false;
return false;
} }
} }
} }
......
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