diff options
author | Tor Egge <Tor.Egge@broadpark.no> | 2018-08-29 14:12:49 +0200 |
---|---|---|
committer | Tor Egge <Tor.Egge@broadpark.no> | 2018-08-29 14:20:13 +0200 |
commit | 860fb32d2a29fb8f69a43d913a3ea6694d036d73 (patch) | |
tree | 8fd458285121165566a42d2cb263f6639bd205ea /staging_vespalib | |
parent | 4b4ee6503ad05926218b9a0d01a6ac0846bdf71c (diff) |
Add move assignment and move constructor to CloneablePtr and IdentifiablePtr.
This allows for use of std::unique_ptr rhs value instead of temporary
raw pointer.
Diffstat (limited to 'staging_vespalib')
-rw-r--r-- | staging_vespalib/src/vespa/vespalib/objects/identifiable.hpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/staging_vespalib/src/vespa/vespalib/objects/identifiable.hpp b/staging_vespalib/src/vespa/vespalib/objects/identifiable.hpp index ad31712ede9..2c34ba306ab 100644 --- a/staging_vespalib/src/vespa/vespalib/objects/identifiable.hpp +++ b/staging_vespalib/src/vespa/vespalib/objects/identifiable.hpp @@ -51,6 +51,15 @@ public: IdentifiablePtr(const IdentifiablePtr &) = default; IdentifiablePtr & operator = (const IdentifiablePtr &) = default; IdentifiablePtr(T * p=NULL) : CloneablePtr<T>(p) { } + IdentifiablePtr(std::unique_ptr<T> &&rhs) + : CloneablePtr<T>(std::move(rhs)) + { + } + IdentifiablePtr &operator=(std::unique_ptr<T> &&rhs) + { + CloneablePtr<T>::operator=(std::move(rhs)); + return *this; + } int cmp(const IdentifiablePtr<T> &rhs) const { const T *a = this->get(); const T *b = rhs.get(); |