diff --git a/src/wrapper.hh b/src/wrapper.hh index deb48be..1ef0819 100644 --- a/src/wrapper.hh +++ b/src/wrapper.hh @@ -13,6 +13,8 @@ template class Wrapper { public: + typedef T c_type; + template Wrapper(Args... args) : value{ this->_new(args...) } {} @@ -28,6 +30,9 @@ public: Wrapper copy() const; + friend + bool operator==(const Wrapper& a, const Wrapper& b); + private: // must be defined for each wrapped type: template @@ -42,6 +47,8 @@ template class Wrapper { public: + typedef T* c_type; + Wrapper() : value{nullptr} {} template @@ -70,6 +77,11 @@ public: _free(value); } + const T* get() const { return value; } + T* move_out() && { T* r = value; value=nullptr; return r;} + + friend + bool operator==(const Wrapper& a, const Wrapper& b); protected: @@ -84,6 +96,13 @@ protected: T* value; }; +template +inline +bool operator!=(const Wrapper& a, const Wrapper& b) +{ + return !(a==b); +} + // Wraps single-linked lists and provides an interface compatible // to std::forward_list @@ -114,8 +133,9 @@ public: // I am my own iterator iterator operator++() { return (value ? value = value->next : value); } - Element operator*() { return value->Value; } + Element operator*() { return value->*Value; } + void erase(const iterator& it); void clear(); void push_back(Element&&);