aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/core/SkRefCnt.h
diff options
context:
space:
mode:
authorGravatar mtklein <mtklein@chromium.org>2016-03-16 10:28:35 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-03-16 10:28:35 -0700
commit5f939ab658a228dce34a3b14a545638407150b92 (patch)
tree3eff56fe1aad736cb0e8e07735c06690c5d7d0a4 /include/core/SkRefCnt.h
parentaf1e21e7ebb155d2505da0eb974c672953dfefef (diff)
Use std::unique_ptr.
Diffstat (limited to 'include/core/SkRefCnt.h')
-rw-r--r--include/core/SkRefCnt.h11
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. :(