utils/win/SkTScopedComPtr<T>: Add C++11ish move semantics
Change-Id: I026ffa81d583fddc4a2c7238a176232ef98fcd89 Reviewed-on: https://skia-review.googlesource.com/7434 Reviewed-by: Ben Wagner <bungeman@google.com> Commit-Queue: Hal Canary <halcanary@google.com>
This commit is contained in:
parent
d46697ac36
commit
b2cd1d7b44
@ -32,7 +32,7 @@ template<typename T> T* SkSafeRefComPtr(T* ptr) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
class SkTScopedComPtr : SkNoncopyable {
|
class SkTScopedComPtr {
|
||||||
private:
|
private:
|
||||||
T *fPtr;
|
T *fPtr;
|
||||||
|
|
||||||
@ -41,6 +41,14 @@ public:
|
|||||||
|
|
||||||
~SkTScopedComPtr() { this->reset();}
|
~SkTScopedComPtr() { this->reset();}
|
||||||
|
|
||||||
|
SkTScopedComPtr(SkTScopedComPtr&& that) : fPtr(that.release()) {}
|
||||||
|
SkTScopedComPtr(const SkTScopedComPtr&) = delete;
|
||||||
|
SkTScopedComPtr& operator=(SkTScopedComPtr&& that) {
|
||||||
|
this->reset(that.release());
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
SkTScopedComPtr& operator=(const SkTScopedComPtr&) = delete;
|
||||||
|
|
||||||
T &operator*() const { SkASSERT(fPtr != nullptr); return *fPtr; }
|
T &operator*() const { SkASSERT(fPtr != nullptr); return *fPtr; }
|
||||||
|
|
||||||
explicit operator bool() const { return fPtr != nullptr; }
|
explicit operator bool() const { return fPtr != nullptr; }
|
||||||
|
Loading…
Reference in New Issue
Block a user