aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/core/SkRefCnt.h
diff options
context:
space:
mode:
authorGravatar mtklein <mtklein@chromium.org>2016-01-24 19:18:54 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-01-24 19:18:54 -0800
commitccf1de0d9aa75f29829f1c4c462214b991fd8c9e (patch)
tree20460f16ab9a5efaee8374406e9dc680f155d13f /include/core/SkRefCnt.h
parent3b69b82b22ba854f9a8e9f1ccb54f0d9022c0bd8 (diff)
skstd -> std for unique_ptr
TBR=reed@google.com No public API changes. BUG=skia:4564 Committed: https://skia.googlesource.com/skia/+/755c553c17b82bb5de3d9cc8d3b2a866ff9e9e50 CQ_EXTRA_TRYBOTS=client.skia.compile:Build-Mac10.9-Clang-x86_64-Release-CMake-Trybot,Build-Ubuntu-GCC-x86_64-Debug-CrOS_Link-Trybot;client.skia:Perf-Mac10.9-Clang-MacMini6.2-CPU-AVX-x86_64-Release-Trybot,Test-iOS-Clang-iPad4-GPU-SGX554-Arm7-Release-Trybot Committed: https://skia.googlesource.com/skia/+/06189155d987db5c7e69015f6ea87c2168d6a065 Committed: https://skia.googlesource.com/skia/+/70e8dfca4a7f5bce97b8021a6e378c4828b09c8c Committed: https://skia.googlesource.com/skia/+/dadfc245cc9a0279ff7b73da3344f2ca5d139907 GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1436033003 Review URL: https://codereview.chromium.org/1436033003
Diffstat (limited to 'include/core/SkRefCnt.h')
-rw-r--r--include/core/SkRefCnt.h20
1 files changed, 15 insertions, 5 deletions
diff --git a/include/core/SkRefCnt.h b/include/core/SkRefCnt.h
index 9d1e5f1f02..1779278c6f 100644
--- a/include/core/SkRefCnt.h
+++ b/include/core/SkRefCnt.h
@@ -9,8 +9,8 @@
#define SkRefCnt_DEFINED
#include "../private/SkAtomics.h"
-#include "../private/SkUniquePtr.h"
#include "SkTypes.h"
+#include <memory>
/** \class SkRefCntBase
@@ -185,12 +185,22 @@ 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:
- explicit SkAutoTUnref(T* obj = nullptr) : skstd::unique_ptr<T, SkTUnref<T>>(obj) {}
+ explicit SkAutoTUnref(T* obj = nullptr) : fPtr(obj) {}
- T* detach() { return this->release(); }
- operator T*() const { return this->get(); }
+ void swap(SkAutoTUnref& 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); }
+ T* detach() { return fPtr.release(); }
+ T* release() { return fPtr.release(); }
+
+private:
+ std::unique_ptr<T, SkTUnref<T>> fPtr;
};
// Can't use the #define trick below to guard a bare SkAutoTUnref(...) because it's templated. :(