diff options
author | 2016-03-16 08:39:41 -0700 | |
---|---|---|
committer | 2016-03-16 08:39:42 -0700 | |
commit | 2691d76a06e1af6282f8b3a3140cc93361be10c4 (patch) | |
tree | 61ce9609bafd5df2b6303cf853542ac3dc77247e /include/core/SkRefCnt.h | |
parent | 935f1b1a20f673b81e78bec913cd702ffc793c99 (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
Review URL: https://codereview.chromium.org/1780933003
Diffstat (limited to 'include/core/SkRefCnt.h')
-rw-r--r-- | include/core/SkRefCnt.h | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/include/core/SkRefCnt.h b/include/core/SkRefCnt.h index f159e3b1b7..d18a63a49f 100644 --- a/include/core/SkRefCnt.h +++ b/include/core/SkRefCnt.h @@ -9,9 +9,10 @@ #define SkRefCnt_DEFINED #include "../private/SkAtomics.h" -#include "../private/SkUniquePtr.h" +#include "../private/SkTLogic.h" #include "SkTypes.h" #include <functional> +#include <memory> #include <utility> #define SK_SUPPORT_TRANSITION_TO_SP_INTERFACES @@ -189,12 +190,16 @@ template <typename T> struct SkTUnref { /** * Utility class that simply unref's its argument in the destructor. */ -template <typename T> class SkAutoTUnref : public skstd::unique_ptr<T, SkTUnref<T>> { +template <typename T> class SkAutoTUnref : public std::unique_ptr<T, SkTUnref<T>> { public: - explicit SkAutoTUnref(T* obj = nullptr) : skstd::unique_ptr<T, SkTUnref<T>>(obj) {} + explicit SkAutoTUnref(T* obj = nullptr) : std::unique_ptr<T, SkTUnref<T>>(obj) {} T* detach() { return this->release(); } operator T*() const { return this->get(); } + + // Android's std::unique_ptr's operator bool() is sometimes not explicit... + // so override it with our own explcitly explicit version. + explicit operator bool() const { return this->get() != nullptr; } }; // Can't use the #define trick below to guard a bare SkAutoTUnref(...) because it's templated. :( |