24 std::unique_ptr<T> ptr{};
30 Deep_ptr(std::unique_ptr<T> &&uptr) : ptr(std::move(uptr)) {}
36 template <typename U, typename = std::enable_if_t<std::is_base_of<T, U>::value>>
40 template <typename U, typename = std::enable_if_t<std::is_base_of<T, U>::value>>
41 Deep_ptr(
const std::unique_ptr<U> &other) : ptr(other ? other->copy() : nullptr) {}
47 template <typename U, typename = std::enable_if_t<std::is_base_of<T, U>::value>>
61 if (
this != &other) ptr = other ? other->copy() :
nullptr;
69 if (
this != &other) ptr = std::move(other.ptr);
76 T *
get()
const {
return ptr.get(); }
79 explicit operator bool()
const {
return static_cast<bool>(ptr); }
80 void reset(T *p =
nullptr) { ptr.reset(p); }
88 return lhs.ptr ==
nullptr;
93 return rhs ==
nullptr;
98 return !(lhs ==
nullptr);
103 return rhs !=
nullptr;
108template <
typename T,
typename... Args>
111 return Deep_ptr<T>(
new T(std::forward<Args>(args)...));
119template <
typename T,
typename... Args>
Definition: Deep_ptr.hpp:23
Deep_ptr(T *p)
Constructor taking a raw pointer.
Definition: Deep_ptr.hpp:28
Deep_ptr(const Deep_ptr< U > &other)
Definition: Deep_ptr.hpp:37
friend bool operator!=(std::nullptr_t, const Deep_ptr< T > &rhs) noexcept
Definition: Deep_ptr.hpp:101
friend bool operator==(std::nullptr_t, const Deep_ptr< T > &rhs) noexcept
Definition: Deep_ptr.hpp:91
Deep_ptr & operator=(const Deep_ptr &other)
Copy assignment operator.
Definition: Deep_ptr.hpp:59
void swap(Deep_ptr &other)
Definition: Deep_ptr.hpp:83
Deep_ptr()=default
Default constructor.
Deep_ptr(std::unique_ptr< T > &&uptr)
Definition: Deep_ptr.hpp:30
friend bool operator!=(const Deep_ptr< T > &lhs, std::nullptr_t) noexcept
Definition: Deep_ptr.hpp:96
friend bool operator==(const Deep_ptr< T > &lhs, std::nullptr_t) noexcept
Definition: Deep_ptr.hpp:86
Deep_ptr(const std::unique_ptr< U > &other)
Definition: Deep_ptr.hpp:41
T & operator*() const
Dereference operator.
Definition: Deep_ptr.hpp:75
void reset(T *p=nullptr)
Reset the Deep_ptr.
Definition: Deep_ptr.hpp:80
Deep_ptr & operator=(Deep_ptr &&other) noexcept
Move assignment operator.
Definition: Deep_ptr.hpp:67
T * get() const
Get the raw pointer.
Definition: Deep_ptr.hpp:76
Deep_ptr(Deep_ptr &&other) noexcept
Move constructor.
Definition: Deep_ptr.hpp:44
T * operator->() const
Accessor operator.
Definition: Deep_ptr.hpp:74
Deep_ptr(Deep_ptr< U > &&other) noexcept
Definition: Deep_ptr.hpp:48
Deep_ptr(const Deep_ptr &other)
Copy constructor.
Definition: Deep_ptr.hpp:33
Slide namespace contains all the types, classes, and functions for the simulation framework.
Definition: Cell.hpp:27
Deep_ptr< T > make(Args &&...args)
Makes storage units.
Definition: Deep_ptr.hpp:120
Deep_ptr< T > make_Deep_ptr(Args &&...args)
Definition: Deep_ptr.hpp:109