25 #ifndef __I6ENGINE_UTILS_WEAKPTR_H__
26 #define __I6ENGINE_UTILS_WEAKPTR_H__
37 template<
typename T,
typename Base = T>
49 weakPtr(
const weakPtr & other) : _sharedPtrWrapper(other._sharedPtrWrapper), _ptr(other._ptr) {
55 weakPtr(
weakPtr && other) : _sharedPtrWrapper(other._sharedPtrWrapper), _ptr(other._ptr) {
56 other._sharedPtrWrapper.reset();
76 template<
typename U,
typename V>
93 _sharedPtrWrapper = other._sharedPtrWrapper;
103 if (*
this == other) {
106 _sharedPtrWrapper = other._sharedPtrWrapper;
108 other._sharedPtrWrapper.reset();
109 other._ptr =
nullptr;
118 return _ptr == other._ptr;
125 return _ptr == other;
129 return !(*
this == other);
133 return !(*
this == other);
137 return _ptr < other._ptr;
144 auto p = _sharedPtrWrapper.lock();
152 return _sharedPtrWrapper.expired();
156 std::weak_ptr<sharedPtrWrapper<Base>> _sharedPtrWrapper;
weakPtr(weakPtr &&other)
move constructor
const weakPtr & operator=(const weakPtr &other)
assignment operator
A weak pointer observing a sharedPtr.
struct handling threadsafe destruction of the wrapped pointer
bool expired() const
return true, if pointer is invalid, otherwise false
weakPtr(const weakPtr &other)
copy constructor copying another weak pointer
bool operator<(const weakPtr &other) const
weakPtr(const sharedPtr< U, V > &other)
constructor takes sharedPtr with different types
bool operator!=(const T *other) const
A shared pointer counting references and adds objects being not referenced any more to an internal li...
weakPtr()
default constructor
~weakPtr()
destructor, removes sharedPtrWrapper if all weak and sharedPtr are removed
bool operator!=(const weakPtr &other) const
bool operator==(const weakPtr &other) const
comparison between two weak pointer
bool operator==(const T *other) const
comparison between weak and normal pointer
sharedPtr< T, U > make_shared(Args &&...)
const weakPtr & operator=(weakPtr &&other)
move assignment operator
weakPtr(const sharedPtr< T, Base > &other)
constructor takes sharedPtr with same base class
weakPtr(const sharedPtr< U, T > &other)
constructor takes sharedPtr with same base class