diff options
author | Abseil Team <absl-team@google.com> | 2018-10-04 22:28:05 (GMT) |
---|---|---|
committer | Gennadiy Civil <misterg@google.com> | 2018-10-05 16:54:14 (GMT) |
commit | 4bb49ed640e34e23187ad7ea689693ef9927033f (patch) | |
tree | 31bfca77d3e46134fddebe28118bcba3af711e45 /googletest/samples/sample3-inl.h | |
parent | f13bbe2992d188e834339abe6f715b2b2f840a77 (diff) | |
download | googletest-4bb49ed640e34e23187ad7ea689693ef9927033f.zip googletest-4bb49ed640e34e23187ad7ea689693ef9927033f.tar.gz googletest-4bb49ed640e34e23187ad7ea689693ef9927033f.tar.bz2 |
Apply clang-tidy modernize-use-nullptr to googletest.
Now that googletest has moved to C++11, it should no longer
use NULL or 0 for the null pointer. This patch converts all
such usages to nullptr using clang-tidy.
This prevents LLVM from issuing -Wzero-as-null-pointer-constant
warnings.
PiperOrigin-RevId: 215814400
Diffstat (limited to 'googletest/samples/sample3-inl.h')
-rw-r--r-- | googletest/samples/sample3-inl.h | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/googletest/samples/sample3-inl.h b/googletest/samples/sample3-inl.h index 1a29ce9..80ba6b9 100644 --- a/googletest/samples/sample3-inl.h +++ b/googletest/samples/sample3-inl.h @@ -58,7 +58,8 @@ class QueueNode { private: // Creates a node with a given element value. The next pointer is // set to NULL. - explicit QueueNode(const E& an_element) : element_(an_element), next_(NULL) {} + explicit QueueNode(const E& an_element) + : element_(an_element), next_(nullptr) {} // We disable the default assignment operator and copy c'tor. const QueueNode& operator = (const QueueNode&); @@ -72,7 +73,7 @@ template <typename E> // E is the element type. class Queue { public: // Creates an empty queue. - Queue() : head_(NULL), last_(NULL), size_(0) {} + Queue() : head_(nullptr), last_(nullptr), size_(0) {} // D'tor. Clears the queue. ~Queue() { Clear(); } @@ -86,12 +87,12 @@ class Queue { for (; ;) { delete node; node = next; - if (node == NULL) break; + if (node == nullptr) break; next = node->next(); } // 2. Resets the member variables. - head_ = last_ = NULL; + head_ = last_ = nullptr; size_ = 0; } } @@ -128,14 +129,14 @@ class Queue { // the queue is empty. E* Dequeue() { if (size_ == 0) { - return NULL; + return nullptr; } const QueueNode<E>* const old_head = head_; head_ = head_->next_; size_--; if (size_ == 0) { - last_ = NULL; + last_ = nullptr; } E* element = new E(old_head->element()); @@ -150,7 +151,8 @@ class Queue { template <typename F> Queue* Map(F function) const { Queue* new_queue = new Queue(); - for (const QueueNode<E>* node = head_; node != NULL; node = node->next_) { + for (const QueueNode<E>* node = head_; node != nullptr; + node = node->next_) { new_queue->Enqueue(function(node->element())); } |