diff options
author | mtklein <mtklein@chromium.org> | 2016-03-16 10:28:35 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-16 10:28:35 -0700 |
commit | 5f939ab658a228dce34a3b14a545638407150b92 (patch) | |
tree | 3eff56fe1aad736cb0e8e07735c06690c5d7d0a4 /include/private/SkTemplates.h | |
parent | af1e21e7ebb155d2505da0eb974c672953dfefef (diff) |
Use std::unique_ptr.
TBR=reed@google.com
Committed: https://skia.googlesource.com/skia/+/20c1e3abfc681771f73eb19fde7284196e028940
Committed: https://skia.googlesource.com/skia/+/3dd9ed37c24611af86f0fe374bd3698b63f09450
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1780933003
Committed: https://skia.googlesource.com/skia/+/2691d76a06e1af6282f8b3a3140cc93361be10c4
Review URL: https://codereview.chromium.org/1780933003
Diffstat (limited to 'include/private/SkTemplates.h')
-rw-r--r-- | include/private/SkTemplates.h | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/include/private/SkTemplates.h b/include/private/SkTemplates.h index e36910e814..811b817d22 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 @@ -58,9 +58,9 @@ template <typename R, typename T, R (*P)(T*)> struct SkFunctionWrapper { function. */ template <typename T, void (*P)(T*)> class SkAutoTCallVProc - : public skstd::unique_ptr<T, SkFunctionWrapper<void, T, P>> { + : public std::unique_ptr<T, SkFunctionWrapper<void, T, P>> { public: - SkAutoTCallVProc(T* obj): skstd::unique_ptr<T, SkFunctionWrapper<void, T, P>>(obj) {} + SkAutoTCallVProc(T* obj): std::unique_ptr<T, SkFunctionWrapper<void, T, P>>(obj) {} operator T*() const { return this->get(); } T* detach() { return this->release(); } @@ -75,9 +75,9 @@ reference is null when the destructor is called, we do not call the function. */ template <typename T, int (*P)(T*)> class SkAutoTCallIProc - : public skstd::unique_ptr<T, SkFunctionWrapper<int, T, P>> { + : public std::unique_ptr<T, SkFunctionWrapper<int, T, P>> { public: - SkAutoTCallIProc(T* obj): skstd::unique_ptr<T, SkFunctionWrapper<int, T, P>>(obj) {} + SkAutoTCallIProc(T* obj): std::unique_ptr<T, SkFunctionWrapper<int, T, P>>(obj) {} operator T*() const { return this->get(); } T* detach() { return this->release(); } @@ -93,18 +93,21 @@ public: The size of a SkAutoTDelete is small: sizeof(SkAutoTDelete<T>) == sizeof(T*) */ -template <typename T> class SkAutoTDelete : public skstd::unique_ptr<T> { +template <typename T> class SkAutoTDelete : public std::unique_ptr<T> { public: - SkAutoTDelete(T* obj = NULL) : skstd::unique_ptr<T>(obj) {} + SkAutoTDelete(T* obj = NULL) : std::unique_ptr<T>(obj) {} operator T*() const { return this->get(); } void free() { this->reset(nullptr); } T* detach() { return this->release(); } + + // See SkAutoTUnref for why we do this. + explicit operator bool() const { return this->get() != nullptr; } }; -template <typename T> class SkAutoTDeleteArray : public skstd::unique_ptr<T[]> { +template <typename T> class SkAutoTDeleteArray : public std::unique_ptr<T[]> { public: - SkAutoTDeleteArray(T array[]) : skstd::unique_ptr<T[]>(array) {} + SkAutoTDeleteArray(T array[]) : std::unique_ptr<T[]>(array) {} void free() { this->reset(nullptr); } T* detach() { return this->release(); } |