Commit 7c9b8cf5 authored by neverlord's avatar neverlord

iterator interface

parent ff1724f7
...@@ -234,8 +234,11 @@ bool matches(std::integral_constant<int, 0>, ...@@ -234,8 +234,11 @@ bool matches(std::integral_constant<int, 0>,
// compare values only (types are guaranteed to be equal) // compare values only (types are guaranteed to be equal)
for (auto i = tpl.begin(); i != end; ++i, ++j) for (auto i = tpl.begin(); i != end; ++i, ++j)
{ {
if ( j->second != nullptr if ( j.value() != nullptr
&& i->first->equals(i->second, j->second) == false) return false; && i.type()->equals(i.value(), j.value()) == false)
{
return false;
}
} }
} }
} }
...@@ -246,9 +249,12 @@ bool matches(std::integral_constant<int, 0>, ...@@ -246,9 +249,12 @@ bool matches(std::integral_constant<int, 0>,
// compares type and value // compares type and value
for (auto i = tpl.begin(); i != end; ++i, ++j) for (auto i = tpl.begin(); i != end; ++i, ++j)
{ {
if ( i->first != j->first if ( i.type() != j.type()
|| ( j->second != nullptr || ( j.value() != nullptr
&& i->first->equals(i->second, j->second) == false)) return false; && i.type()->equals(i.value(), j.value()) == false))
{
return false;
}
} }
} }
else else
...@@ -256,7 +262,7 @@ bool matches(std::integral_constant<int, 0>, ...@@ -256,7 +262,7 @@ bool matches(std::integral_constant<int, 0>,
// compares the types only // compares the types only
for (auto i = tpl.begin(); i != end; ++i, ++j) for (auto i = tpl.begin(); i != end; ++i, ++j)
{ {
if (i->first != j->first) return false; if (i.type() != j.type()) return false;
} }
} }
} }
......
...@@ -77,7 +77,7 @@ struct types_array_impl ...@@ -77,7 +77,7 @@ struct types_array_impl
{ {
return data[p]; return data[p];
} }
typedef type_value_pair const* const_iterator; typedef type_value_pair_const_iterator const_iterator;
inline const_iterator begin() const { return pairs; } inline const_iterator begin() const { return pairs; }
inline const_iterator end() const { return pairs + sizeof...(T); } inline const_iterator end() const { return pairs + sizeof...(T); }
}; };
...@@ -121,7 +121,7 @@ struct types_array_impl<false, T...> ...@@ -121,7 +121,7 @@ struct types_array_impl<false, T...>
} }
return result; return result;
} }
typedef type_value_pair const* const_iterator; typedef type_value_pair_const_iterator const_iterator;
inline const_iterator begin() const inline const_iterator begin() const
{ {
auto result = pairs.load(); auto result = pairs.load();
......
...@@ -84,50 +84,8 @@ class pattern ...@@ -84,50 +84,8 @@ class pattern
typedef util::fixed_vector<size_t, filtered_types::size> mapping_vector; typedef util::fixed_vector<size_t, filtered_types::size> mapping_vector;
class const_iterator typedef type_value_pair_const_iterator const_iterator;
{
type_value_pair const* iter;
public:
const_iterator(type_value_pair const* i) : iter(i) { }
const_iterator(const_iterator const&) = default;
inline uniform_type_info const* type() const { return iter->first; }
inline void const* value() const { return iter->second; }
inline decltype(iter) operator->() { return iter; }
inline decltype(*iter) operator*() { return *iter; }
inline const_iterator& operator++()
{
++iter;
return *this;
}
inline const_iterator& operator--()
{
--iter;
return *this;
}
inline bool operator==(const_iterator const& other) const
{
return iter == other.iter;
}
inline bool operator!=(const_iterator const& other) const
{
return iter != other.iter;
}
};
//typedef type_value_pair const* const_iterator;
const_iterator begin() const { return m_ptrs; } const_iterator begin() const { return m_ptrs; }
......
...@@ -37,6 +37,54 @@ namespace cppa { ...@@ -37,6 +37,54 @@ namespace cppa {
typedef std::pair<uniform_type_info const*, void const*> type_value_pair; typedef std::pair<uniform_type_info const*, void const*> type_value_pair;
class type_value_pair_const_iterator
{
type_value_pair const* iter;
public:
type_value_pair_const_iterator(type_value_pair const* i) : iter(i) { }
type_value_pair_const_iterator(type_value_pair_const_iterator const&) = default;
inline uniform_type_info const* type() const { return iter->first; }
inline void const* value() const { return iter->second; }
inline decltype(iter) operator->() { return iter; }
inline decltype(*iter) operator*() { return *iter; }
inline type_value_pair_const_iterator& operator++()
{
++iter;
return *this;
}
inline type_value_pair_const_iterator& operator--()
{
--iter;
return *this;
}
inline type_value_pair_const_iterator operator+(size_t offset)
{
return iter + offset;
}
inline bool operator==(type_value_pair_const_iterator const& other) const
{
return iter == other.iter;
}
inline bool operator!=(type_value_pair_const_iterator const& other) const
{
return iter != other.iter;
}
};
} // namespace cppa } // namespace cppa
#endif // TYPE_VALUE_PAIR_HPP #endif // TYPE_VALUE_PAIR_HPP
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