Skip to content

Commit

Permalink
COMMON: Implement move constructor of ScopedPtr
Browse files Browse the repository at this point in the history
This helps when passing ScopedPtr as function arguments
  • Loading branch information
lephilousophe committed May 8, 2022
1 parent fe26ec3 commit 5e3d002
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions common/ptr.h
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,14 @@ class ScopedPtr : private NonCopyable, public SafeBool<ScopedPtr<T, DL> > {
explicit ScopedPtr(PointerType o = nullptr) : _pointer(o) {}
ScopedPtr(std::nullptr_t) : _pointer(nullptr) {}

/**
* Move constructor
*/
template<class T2>
ScopedPtr(ScopedPtr<T2> &&o) : _pointer(o._pointer) {
o._pointer = nullptr;
}

ReferenceType operator*() const { return *_pointer; }
PointerType operator->() const { return _pointer; }

Expand Down

0 comments on commit 5e3d002

Please sign in to comment.