Index: include/private/SkTemplates.h |
diff --git a/include/private/SkTemplates.h b/include/private/SkTemplates.h |
index 9776a99631372e46edb0c3a1494910507c19a0ad..496cf427337664d82ed499412e67168af14f8f5b 100644 |
--- a/include/private/SkTemplates.h |
+++ b/include/private/SkTemplates.h |
@@ -13,8 +13,8 @@ |
#include "SkMath.h" |
#include "SkTLogic.h" |
#include "SkTypes.h" |
+#include "SkUniquePtr.h" |
#include <limits.h> |
-#include <memory> |
#include <new> |
/** \file SkTemplates.h |
@@ -57,18 +57,13 @@ |
reference is null when the destructor is called, we do not call the |
function. |
*/ |
-template <typename T, void (*P)(T*)> class SkAutoTCallVProc { |
-public: |
- SkAutoTCallVProc(T* obj) : fPtr(obj) {} |
- |
- T* get() const { return fPtr.get(); } |
- operator T* () const { return fPtr.get(); } |
- T* operator->() const { return fPtr.get(); } |
- |
- T* detach() { return fPtr.release(); } |
- void reset(T* ptr = nullptr) { fPtr.reset(ptr); } |
-private: |
- std::unique_ptr<T, SkFunctionWrapper<void, T, P>> fPtr; |
+template <typename T, void (*P)(T*)> class SkAutoTCallVProc |
+ : public skstd::unique_ptr<T, SkFunctionWrapper<void, T, P>> { |
+public: |
+ SkAutoTCallVProc(T* obj): skstd::unique_ptr<T, SkFunctionWrapper<void, T, P>>(obj) {} |
+ |
+ operator T*() const { return this->get(); } |
+ T* detach() { return this->release(); } |
}; |
/** \class SkAutoTCallIProc |
@@ -79,18 +74,13 @@ |
reference is null when the destructor is called, we do not call the |
function. |
*/ |
-template <typename T, int (*P)(T*)> class SkAutoTCallIProc { |
-public: |
- SkAutoTCallIProc(T* obj) : fPtr(obj) {} |
- |
- T* get() const { return fPtr.get(); } |
- operator T* () const { return fPtr.get(); } |
- T* operator->() const { return fPtr.get(); } |
- |
- T* detach() { return fPtr.release(); } |
- void reset(T* ptr = nullptr) { fPtr.reset(ptr); } |
-private: |
- std::unique_ptr<T, SkFunctionWrapper<int, T, P>> fPtr; |
+template <typename T, int (*P)(T*)> class SkAutoTCallIProc |
+ : public skstd::unique_ptr<T, SkFunctionWrapper<int, T, P>> { |
+public: |
+ SkAutoTCallIProc(T* obj): skstd::unique_ptr<T, SkFunctionWrapper<int, T, P>>(obj) {} |
+ |
+ operator T*() const { return this->get(); } |
+ T* detach() { return this->release(); } |
}; |
/** \class SkAutoTDelete |
@@ -103,27 +93,18 @@ |
The size of a SkAutoTDelete is small: sizeof(SkAutoTDelete<T>) == sizeof(T*) |
*/ |
-template <typename T> class SkAutoTDelete { |
-public: |
- SkAutoTDelete(T* obj = NULL) : fPtr(obj) {} |
- |
- void swap(SkAutoTDelete& other) { fPtr.swap(other.fPtr); } |
- |
- T* get() const { return fPtr.get(); } |
- operator T* () const { return fPtr.get(); } |
- T* operator->() const { return fPtr.get(); } |
- |
- void reset(T* ptr = nullptr) { fPtr.reset(ptr); } |
- void free() { fPtr.reset(nullptr); } |
- T* detach() { return fPtr.release(); } |
- T* release() { return fPtr.release(); } |
-private: |
- std::unique_ptr<T> fPtr; |
-}; |
- |
-template <typename T> class SkAutoTDeleteArray : public std::unique_ptr<T[]> { |
-public: |
- SkAutoTDeleteArray(T array[]) : std::unique_ptr<T[]>(array) {} |
+template <typename T> class SkAutoTDelete : public skstd::unique_ptr<T> { |
+public: |
+ SkAutoTDelete(T* obj = NULL) : skstd::unique_ptr<T>(obj) {} |
+ |
+ operator T*() const { return this->get(); } |
+ void free() { this->reset(nullptr); } |
+ T* detach() { return this->release(); } |
+}; |
+ |
+template <typename T> class SkAutoTDeleteArray : public skstd::unique_ptr<T[]> { |
+public: |
+ SkAutoTDeleteArray(T array[]) : skstd::unique_ptr<T[]>(array) {} |
void free() { this->reset(nullptr); } |
T* detach() { return this->release(); } |