|
|
|
@ -13,6 +13,8 @@ template<class T>
|
|
|
|
|
class Wrapper
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
typedef T c_type;
|
|
|
|
|
|
|
|
|
|
template<class... Args>
|
|
|
|
|
Wrapper(Args... args) : value{ this->_new(args...) } {}
|
|
|
|
|
|
|
|
|
@ -28,6 +30,9 @@ public:
|
|
|
|
|
|
|
|
|
|
Wrapper<T> copy() const;
|
|
|
|
|
|
|
|
|
|
friend
|
|
|
|
|
bool operator==(const Wrapper<T>& a, const Wrapper<T>& b);
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
// must be defined for each wrapped type:
|
|
|
|
|
template<class... Args>
|
|
|
|
@ -42,6 +47,8 @@ template<class T>
|
|
|
|
|
class Wrapper<T*>
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
typedef T* c_type;
|
|
|
|
|
|
|
|
|
|
Wrapper() : value{nullptr} {}
|
|
|
|
|
|
|
|
|
|
template<class... Args>
|
|
|
|
@ -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<T*>& a, const Wrapper<T*>& b);
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
|
@ -84,6 +96,13 @@ protected:
|
|
|
|
|
T* value;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
template<class T>
|
|
|
|
|
inline
|
|
|
|
|
bool operator!=(const Wrapper<T>& a, const Wrapper<T>& 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&&);
|
|
|
|
|
|
|
|
|
|