|
|
@ -116,25 +116,38 @@ class ListWrapper<T*, Element> : public Wrapper<T*> |
|
|
|
public: |
|
|
|
struct Trait; |
|
|
|
typedef Wrapper<T*> Base; |
|
|
|
typedef ListWrapper<T*, Element> iterator; // FIXME: different type necessary?
|
|
|
|
|
|
|
|
typedef ListWrapper<T*, Element> LW; |
|
|
|
|
|
|
|
static Element T::* const Value; // to access the current value
|
|
|
|
|
|
|
|
using Base::Base; |
|
|
|
// does not own the *value
|
|
|
|
class iterator |
|
|
|
{ |
|
|
|
public: |
|
|
|
iterator() = default; |
|
|
|
|
|
|
|
iterator operator++() { return (value ? value = value->next : value); } |
|
|
|
Element operator*() { return value->*LW::Value; } |
|
|
|
bool operator==(const iterator& other) const { return value == other.value; } |
|
|
|
bool operator!=(const iterator& other) const { return value != other.value; } |
|
|
|
|
|
|
|
private: |
|
|
|
iterator(T* _t) : value{_t} {} |
|
|
|
T* value = nullptr; |
|
|
|
friend class ListWrapper<T*, Element>; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
using Base::value; |
|
|
|
|
|
|
|
ListWrapper() : Base() {} |
|
|
|
ListWrapper(const std::initializer_list<Element>& i); |
|
|
|
ListWrapper(const std::initializer_list<pEp::Wrapper<Element> >& i); |
|
|
|
|
|
|
|
iterator begin() { return value; } |
|
|
|
iterator begin() { return iterator{value}; } |
|
|
|
iterator end() const { return iterator{}; } |
|
|
|
int size() const; |
|
|
|
bool empty() const; |
|
|
|
|
|
|
|
// I am my own iterator
|
|
|
|
iterator operator++() { return (value ? value = value->next : value); } |
|
|
|
Element operator*() { return value->*Value; } |
|
|
|
|
|
|
|
void erase(const iterator& it); |
|
|
|
void clear(); |
|
|
|
void push_back(Element&&); |
|
|
|