SkTScopedComPtr: implicit nullptr cast to SkTScopedComPtr<T>()
Change-Id: Ic09da242650eb20164f31333e912fc899428c548
Reviewed-on: https://skia-review.googlesource.com/7634
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Hal Canary <halcanary@google.com>
diff --git a/src/utils/win/SkTScopedComPtr.h b/src/utils/win/SkTScopedComPtr.h
index b8aeb73..f44740f 100644
--- a/src/utils/win/SkTScopedComPtr.h
+++ b/src/utils/win/SkTScopedComPtr.h
@@ -37,17 +37,20 @@
T *fPtr;
public:
- explicit SkTScopedComPtr(T *ptr = nullptr) : fPtr(ptr) { }
+ constexpr SkTScopedComPtr() : fPtr(nullptr) {}
+ constexpr SkTScopedComPtr(std::nullptr_t) : fPtr(nullptr) {}
+ explicit SkTScopedComPtr(T *ptr) : fPtr(ptr) {}
+ SkTScopedComPtr(SkTScopedComPtr&& that) : fPtr(that.release()) {}
+ SkTScopedComPtr(const SkTScopedComPtr&) = delete;
~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;
+ SkTScopedComPtr& operator=(std::nullptr_t) { this->reset(); return *this; }
T &operator*() const { SkASSERT(fPtr != nullptr); return *fPtr; }