Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(294)

Unified Diff: include/core/SkRefCnt.h

Issue 1780933003: Use std::unique_ptr. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: once more, all together Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gyp/core.gypi ('k') | include/gpu/gl/SkGLContext.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkRefCnt.h
diff --git a/include/core/SkRefCnt.h b/include/core/SkRefCnt.h
index f159e3b1b705cb70aa63bb540d448241701c0c06..d18a63a49ffdc63e978b4a993ecd497f4a093caf 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. :(
« no previous file with comments | « gyp/core.gypi ('k') | include/gpu/gl/SkGLContext.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698