29 #ifndef AURORA_COPIEDPTR_HPP
30 #define AURORA_COPIEDPTR_HPP
33 #include <Aurora/SmartPtr/Detail/PtrOwner.hpp>
39 #include <type_traits>
96 template <
typename U,
typename C>
98 : mOwner( detail::newPtrOwner<T>(pointer, cloner,
OperatorDelete<U>()) )
108 template <
typename U,
typename C,
typename D>
110 : mOwner( detail::newPtrOwner<T>(pointer, cloner, deleter) )
120 : mOwner(origin ? origin.mOwner->clone() : nullptr)
121 , mPointer(origin ? mOwner->getPointer() : nullptr)
129 template <
typename U>
131 : mOwner(origin ? new detail::PtrIndirection<T, U>(origin.mOwner, detail::CopyTag()) : nullptr)
132 , mPointer(origin ? mOwner->getPointer() : nullptr)
139 : mOwner(source.mOwner)
140 , mPointer(source.mPointer)
142 source.mOwner =
nullptr;
143 source.mPointer =
nullptr;
150 template <
typename U>
152 : mOwner(source ? new detail::PtrIndirection<T, U>(source.mOwner, detail::MoveTag()) : nullptr)
153 , mPointer(source.mPointer)
155 source.mOwner =
nullptr;
156 source.mPointer =
nullptr;
159 #ifdef AURORA_HAS_VARIADIC_TEMPLATES
163 template <
typename... Args>
164 CopiedPtr(detail::EmplaceTag, Args&&... args)
165 : mOwner(new detail::CompactOwner<T>(detail::EmplaceTag(), std::forward<Args>(args)...))
166 , mPointer(mOwner->getPointer())
170 #endif // AURORA_HAS_VARIADIC_TEMPLATES
184 template <
typename U>
195 CopiedPtr(std::move(source)).swap(*
this);
203 template <
typename U>
206 CopiedPtr(std::move(source)).swap(*
this);
223 adlSwap(mPointer, other.mPointer);
228 AURORA_FAKE_DOC(
typename std::add_lvalue_reference<T>::type, T&) operator* ()
const
267 template <
typename U>
279 template <
typename U,
typename C>
291 template <
typename U,
typename C,
typename D>
292 void reset(U* pointer, C cloner, D deleter)
294 CopiedPtr(pointer, cloner, deleter).swap(*
this);
301 detail::PtrOwnerBase<T>* mOwner;
304 template <
typename T2>
311 template <
typename T>
314 return lhs.
swap(rhs);
319 #ifdef AURORA_HAS_VARIADIC_TEMPLATES
335 template <
typename T,
typename... Args>
338 return CopiedPtr<T>(detail::EmplaceTag(), std::forward<Args>(args)...);
342 #else // AURORA_HAS_VARIADIC_TEMPLATES
344 #include <Aurora/SmartPtr/Detail/Factories.hpp>
347 #define AURORA_DETAIL_COPIEDPTR_FACTORY(n) AURORA_DETAIL_SMARTPTR_FACTORY(CopiedPtr, makeCopied, n)
352 #endif // AURORA_HAS_VARIADIC_TEMPLATES
358 #endif // AURORA_COPIEDPTR_HPP
CopiedPtr(std::nullptr_t)
Construct from nullptr.
Definition: CopiedPtr.hpp:76
CopiedPtr(U *pointer, C cloner, D deleter)
Construct from raw pointer with cloner and deleter.
Definition: CopiedPtr.hpp:109
void reset()
Reset to null pointer.
Definition: CopiedPtr.hpp:259
CopiedPtr()
Default constructor.
Definition: CopiedPtr.hpp:68
void swap(CopiedPtr &other)
Exchanges the values of *this and other.
Definition: CopiedPtr.hpp:220
CopiedPtr(CopiedPtr< U > &&source)
Move from different CopiedPtr.
Definition: CopiedPtr.hpp:151
Configuration header of the library.
Cloner and deleter functors for smart pointers.
CopiedPtr(U *pointer)
Construct from raw pointer.
Definition: CopiedPtr.hpp:85
~CopiedPtr()
Destructor.
Definition: CopiedPtr.hpp:212
CopiedPtr< T > makeCopied(Args &&...args)
Emplaces an object directly inside the copied pointer.
Definition: CopiedPtr.hpp:336
void swap(CopiedPtr< T > &lhs, CopiedPtr< T > &rhs)
Swaps the contents of two CopiedPtr instances.
Definition: CopiedPtr.hpp:312
CopiedPtr(const CopiedPtr &origin)
Copy constructor.
Definition: CopiedPtr.hpp:119
CopiedPtr & operator=(const CopiedPtr &origin)
Copy assignment operator.
Definition: CopiedPtr.hpp:175
void reset(U *pointer, C cloner)
Reset to raw pointer with cloner.
Definition: CopiedPtr.hpp:280
Type aurora::SafeBool and corresponding functionality.
CopiedPtr(U *pointer, C cloner)
Construct from raw pointer with cloner.
Definition: CopiedPtr.hpp:97
void reset(U *pointer, C cloner, D deleter)
Reset to raw pointer with cloner and deleter.
Definition: CopiedPtr.hpp:292
Helpers to declare and invoke swap() functions.
Cloner that invokes the copy constructor and new operator.
Definition: ClonersAndDeleters.hpp:45
Deleter that invokes the delete operator.
Definition: ClonersAndDeleters.hpp:70
Copyable smart pointer template.
Definition: CopiedPtr.hpp:61
void reset(U *pointer)
Reset to raw pointer.
Definition: CopiedPtr.hpp:268
CopiedPtr(CopiedPtr &&source)
Move constructor.
Definition: CopiedPtr.hpp:138
T * operator->() const
Dereferences the pointer for member access.
Definition: CopiedPtr.hpp:236
Definition: DispatchTraits.hpp:39
CopiedPtr(const CopiedPtr< U > &origin)
Construct from different CopiedPtr.
Definition: CopiedPtr.hpp:130