aboutsummaryrefslogtreecommitdiff
path: root/third_party/chromium/base/memory/weak_ptr.h
diff options
context:
space:
mode:
authorLuis Hector Chavez <lhchavez@google.com>2016-06-01 22:32:35 +0000
committerandroid-build-merger <android-build-merger@google.com>2016-06-01 22:32:35 +0000
commit340025151a619931897234503cbebb267d2f8a7a (patch)
tree7f57ba7623a0cbf9621452f92e900095242090d5 /third_party/chromium/base/memory/weak_ptr.h
parent50a175dc8c72fd300b59510dfe308e0ebb2d26ad (diff)
parentda4667b75ad79aa4530b3db12259be303a2cd9a1 (diff)
downloadlibweave-340025151a619931897234503cbebb267d2f8a7a.tar.gz
Reland "Merge remote-tracking branch \'weave/master\' into \'weave/aosp-master\'" am: 83db8f75af am: b20409af35
am: da4667b75a * commit 'da4667b75ad79aa4530b3db12259be303a2cd9a1': Reland "Merge remote-tracking branch 'weave/master' into 'weave/aosp-master'" Change-Id: Ib4befd38226ffb190dad7b78d8a17f75c958ae87
Diffstat (limited to 'third_party/chromium/base/memory/weak_ptr.h')
-rw-r--r--third_party/chromium/base/memory/weak_ptr.h24
1 files changed, 12 insertions, 12 deletions
diff --git a/third_party/chromium/base/memory/weak_ptr.h b/third_party/chromium/base/memory/weak_ptr.h
index 601c379..2efb024 100644
--- a/third_party/chromium/base/memory/weak_ptr.h
+++ b/third_party/chromium/base/memory/weak_ptr.h
@@ -3,7 +3,7 @@
// found in the LICENSE file.
// Weak pointers are pointers to an object that do not affect its lifetime,
-// and which may be invalidated (i.e. reset to NULL) by the object, or its
+// and which may be invalidated (i.e. reset to nullptr) by the object, or its
// owner, at any time, most commonly when the object is about to be deleted.
// Weak pointers are useful when an object needs to be accessed safely by one
@@ -70,6 +70,7 @@
#ifndef BASE_MEMORY_WEAK_PTR_H_
#define BASE_MEMORY_WEAK_PTR_H_
+#include <cstddef>
#include <type_traits>
#include "base/base_export.h"
@@ -197,8 +198,9 @@ template <typename T> class WeakPtrFactory;
template <typename T>
class WeakPtr : public internal::WeakPtrBase {
public:
- WeakPtr() : ptr_(NULL) {
- }
+ WeakPtr() : ptr_(nullptr) {}
+
+ WeakPtr(std::nullptr_t) : ptr_(nullptr) {}
// Allow conversion from U to T provided U "is a" T. Note that this
// is separate from the (implicit) copy constructor.
@@ -206,20 +208,20 @@ class WeakPtr : public internal::WeakPtrBase {
WeakPtr(const WeakPtr<U>& other) : WeakPtrBase(other), ptr_(other.ptr_) {
}
- T* get() const { return ref_.is_valid() ? ptr_ : NULL; }
+ T* get() const { return ref_.is_valid() ? ptr_ : nullptr; }
T& operator*() const {
- DCHECK(get() != NULL);
+ DCHECK(get() != nullptr);
return *get();
}
T* operator->() const {
- DCHECK(get() != NULL);
+ DCHECK(get() != nullptr);
return get();
}
void reset() {
ref_ = internal::WeakReference();
- ptr_ = NULL;
+ ptr_ = nullptr;
}
// Implement "Safe Bool Idiom"
@@ -244,7 +246,7 @@ class WeakPtr : public internal::WeakPtrBase {
typedef T* WeakPtr::*Testable;
public:
- operator Testable() const { return get() ? &WeakPtr::ptr_ : NULL; }
+ operator Testable() const { return get() ? &WeakPtr::ptr_ : nullptr; }
private:
// Explicitly declare comparison operators as required by the "Safe Bool
@@ -263,7 +265,7 @@ class WeakPtr : public internal::WeakPtrBase {
}
// This pointer is only valid when ref_.is_valid() is true. Otherwise, its
- // value is undefined (as opposed to NULL).
+ // value is undefined (as opposed to nullptr).
T* ptr_;
};
@@ -278,9 +280,7 @@ class WeakPtrFactory {
explicit WeakPtrFactory(T* ptr) : ptr_(ptr) {
}
- ~WeakPtrFactory() {
- ptr_ = NULL;
- }
+ ~WeakPtrFactory() { ptr_ = nullptr; }
WeakPtr<T> GetWeakPtr() {
DCHECK(ptr_);