Use nullptr rather than 0 for a null pointer
authorChristopher Dykes <cdykes@fb.com>
Thu, 19 Oct 2017 23:13:58 +0000 (16:13 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Thu, 19 Oct 2017 23:21:01 +0000 (16:21 -0700)
Summary: This time aided by clang-tidy's modernize-use-nullptr check.

Reviewed By: yfeldblum

Differential Revision: D6102739

fbshipit-source-id: aeb4bd0a8078d81cc88b766e0a034a37dd25fd1f

folly/AtomicHashArray-inl.h
folly/AtomicHashMap-inl.h
folly/ConcurrentSkipList.h
folly/FBString.h
folly/Foreach.h
folly/LockTraits.h
folly/small_vector.h
folly/test/FBStringTest.cpp
folly/test/MPMCQueueTest.cpp

index 5b81837953e6ecebca5feddcb187211eb3ec6b9b..f8251f338f3e4981fc5c2b3ea7af046a9254bd7a 100644 (file)
@@ -414,18 +414,17 @@ struct AtomicHashArray<KeyT, ValueT, HashFcn, EqualFcn,
                              IterVal,
                              boost::forward_traversal_tag>
 {
                              IterVal,
                              boost::forward_traversal_tag>
 {
-  explicit aha_iterator() : aha_(0) {}
+  explicit aha_iterator() : aha_(nullptr) {}
 
   // Conversion ctor for interoperability between const_iterator and
   // iterator.  The enable_if<> magic keeps us well-behaved for
   // is_convertible<> (v. the iterator_facade documentation).
   template <class OtherContT, class OtherVal>
 
   // Conversion ctor for interoperability between const_iterator and
   // iterator.  The enable_if<> magic keeps us well-behaved for
   // is_convertible<> (v. the iterator_facade documentation).
   template <class OtherContT, class OtherVal>
-  aha_iterator(const aha_iterator<OtherContT,OtherVal>& o,
-               typename std::enable_if<
-               std::is_convertible<OtherVal*,IterVal*>::value >::type* = 0)
-      : aha_(o.aha_)
-      , offset_(o.offset_)
-  {}
+  aha_iterator(
+      const aha_iterator<OtherContT, OtherVal>& o,
+      typename std::enable_if<
+          std::is_convertible<OtherVal*, IterVal*>::value>::type* = nullptr)
+      : aha_(o.aha_), offset_(o.offset_) {}
 
   explicit aha_iterator(ContT* array, size_t offset)
       : aha_(array)
 
   explicit aha_iterator(ContT* array, size_t offset)
       : aha_(array)
index b4032ab2b2444f890b5e242e52907adf1bcc6cf2..ee3da5da01f8b526d56636a11f24f097718b5891 100644 (file)
@@ -468,19 +468,17 @@ struct AtomicHashMap<KeyT, ValueT, HashFcn, EqualFcn,
     ahm_iterator : boost::iterator_facade<ahm_iterator<ContT, IterVal, SubIt>,
                                           IterVal,
                                           boost::forward_traversal_tag> {
     ahm_iterator : boost::iterator_facade<ahm_iterator<ContT, IterVal, SubIt>,
                                           IterVal,
                                           boost::forward_traversal_tag> {
-  explicit ahm_iterator() : ahm_(0) {}
+  explicit ahm_iterator() : ahm_(nullptr) {}
 
   // Conversion ctor for interoperability between const_iterator and
   // iterator.  The enable_if<> magic keeps us well-behaved for
   // is_convertible<> (v. the iterator_facade documentation).
   template <class OtherContT, class OtherVal, class OtherSubIt>
 
   // Conversion ctor for interoperability between const_iterator and
   // iterator.  The enable_if<> magic keeps us well-behaved for
   // is_convertible<> (v. the iterator_facade documentation).
   template <class OtherContT, class OtherVal, class OtherSubIt>
-  ahm_iterator(const ahm_iterator<OtherContT,OtherVal,OtherSubIt>& o,
-               typename std::enable_if<
-               std::is_convertible<OtherSubIt,SubIt>::value >::type* = 0)
-      : ahm_(o.ahm_)
-      , subMap_(o.subMap_)
-      , subIt_(o.subIt_)
-  {}
+  ahm_iterator(
+      const ahm_iterator<OtherContT, OtherVal, OtherSubIt>& o,
+      typename std::enable_if<
+          std::is_convertible<OtherSubIt, SubIt>::value>::type* = nullptr)
+      : ahm_(o.ahm_), subMap_(o.subMap_), subIt_(o.subIt_) {}
 
   /*
    * Returns the unique index that can be used for access directly
 
   /*
    * Returns the unique index that can be used for access directly
index 7d511aadefd53ef5ed0f1355b92c6aeeb4c4fb02..a4b749bbd92280ed481174dac56f82ccf031a011 100644 (file)
@@ -676,9 +676,11 @@ class detail::csl_iterator :
   explicit csl_iterator(NodeT* node = nullptr) : node_(node) {}
 
   template <typename OtherVal, typename OtherNode>
   explicit csl_iterator(NodeT* node = nullptr) : node_(node) {}
 
   template <typename OtherVal, typename OtherNode>
-  csl_iterator(const csl_iterator<OtherVal, OtherNode> &other,
-      typename std::enable_if<std::is_convertible<OtherVal, ValT>::value>::type*
-      = 0) : node_(other.node_) {}
+  csl_iterator(
+      const csl_iterator<OtherVal, OtherNode>& other,
+      typename std::enable_if<
+          std::is_convertible<OtherVal, ValT>::value>::type* = nullptr)
+      : node_(other.node_) {}
 
   size_t nodeSize() const {
     return node_ == nullptr ? 0 :
 
   size_t nodeSize() const {
     return node_ == nullptr ? 0 :
index 731b3d9c466100f01ea0fe89ec57f7aa11a63361..af49ebe0936787aace9a561f9fb20c5d7561424e 100644 (file)
@@ -2333,7 +2333,7 @@ basic_fbstring<E, T, A, S>::find_first_of(
   }
   const_iterator i(begin() + pos), finish(end());
   for (; i != finish; ++i) {
   }
   const_iterator i(begin() + pos), finish(end());
   for (; i != finish; ++i) {
-    if (traits_type::find(s, n, *i) != 0) {
+    if (traits_type::find(s, n, *i) != nullptr) {
       return i - begin();
     }
   }
       return i - begin();
     }
   }
@@ -2348,7 +2348,7 @@ basic_fbstring<E, T, A, S>::find_last_of(
     pos = std::min(pos, length() - 1);
     const_iterator i(begin() + pos);
     for (;; --i) {
     pos = std::min(pos, length() - 1);
     const_iterator i(begin() + pos);
     for (;; --i) {
-      if (traits_type::find(s, n, *i) != 0) {
+      if (traits_type::find(s, n, *i) != nullptr) {
         return i - begin();
       }
       if (i == begin()) {
         return i - begin();
       }
       if (i == begin()) {
@@ -2366,7 +2366,7 @@ basic_fbstring<E, T, A, S>::find_first_not_of(
   if (pos < length()) {
     const_iterator i(begin() + pos), finish(end());
     for (; i != finish; ++i) {
   if (pos < length()) {
     const_iterator i(begin() + pos), finish(end());
     for (; i != finish; ++i) {
-      if (traits_type::find(s, n, *i) == 0) {
+      if (traits_type::find(s, n, *i) == nullptr) {
         return i - begin();
       }
     }
         return i - begin();
       }
     }
@@ -2382,7 +2382,7 @@ basic_fbstring<E, T, A, S>::find_last_not_of(
     pos = std::min(pos, size() - 1);
     const_iterator i(begin() + pos);
     for (;; --i) {
     pos = std::min(pos, size() - 1);
     const_iterator i(begin() + pos);
     for (;; --i) {
-      if (traits_type::find(s, n, *i) == 0) {
+      if (traits_type::find(s, n, *i) == nullptr) {
         return i - begin();
       }
       if (i == begin()) {
         return i - begin();
       }
       if (i == begin()) {
index 50740f40dc1243c000bf27daeb5ac47a277eaa43..ae0e865d92340c82608f47fe1f87142f0d01ae48 100644 (file)
@@ -216,7 +216,7 @@ class HasLess {
   template <typename, typename> static BiggerThanChar test(...);
 
  public:
   template <typename, typename> static BiggerThanChar test(...);
 
  public:
-  enum { value = sizeof(test<T, U>(0)) == 1 };
+  enum { value = sizeof(test<T, U>(nullptr)) == 1 };
 };
 
 /**
 };
 
 /**
index 983831e063002330a0dda0596c6fe203a81d8f26..a6cf12b596f03896bc8f28716132bb71e2254e45 100644 (file)
@@ -106,11 +106,11 @@ class LockInterfaceDispatcher {
  public:
   static constexpr bool has_lock_unique = true;
   static constexpr bool has_lock_timed =
  public:
   static constexpr bool has_lock_unique = true;
   static constexpr bool has_lock_timed =
-      decltype(timed_lock_test<Mutex>(0))::value;
+      decltype(timed_lock_test<Mutex>(nullptr))::value;
   static constexpr bool has_lock_shared =
   static constexpr bool has_lock_shared =
-      decltype(lock_shared_test<Mutex>(0))::value;
+      decltype(lock_shared_test<Mutex>(nullptr))::value;
   static constexpr bool has_lock_upgrade =
   static constexpr bool has_lock_upgrade =
-      decltype(lock_upgrade_test<Mutex>(0))::value;
+      decltype(lock_upgrade_test<Mutex>(nullptr))::value;
 };
 
 /**
 };
 
 /**
index b8009b018acf4e1231fc20a13a772ce71518a24c..71440437f672b4978c5746b83f23582377ba8907 100644 (file)
@@ -1137,7 +1137,7 @@ class small_vector : public detail::small_vector_base<
 
   union Data {
     explicit Data() {
 
   union Data {
     explicit Data() {
-      pdata_.heap_ = 0;
+      pdata_.heap_ = nullptr;
     }
 
     PointerType pdata_;
     }
 
     PointerType pdata_;
index 64343b405ff03d41579bf282a85e67ee99b7ba77..6ded8b4c0215a09e55837d88fe60c1c73c2ed636 100644 (file)
@@ -1236,7 +1236,7 @@ TEST(FBString, testMoveOperatorPlusRhs) {
 //      other than libstdc++. Someday if we deem it important to present
 //      identical undefined behavior for other platforms, we can re-visit this.
 TEST(FBString, testConstructionFromLiteralZero) {
 //      other than libstdc++. Someday if we deem it important to present
 //      identical undefined behavior for other platforms, we can re-visit this.
 TEST(FBString, testConstructionFromLiteralZero) {
-  EXPECT_THROW(fbstring s(0), std::logic_error);
+  EXPECT_THROW(fbstring s(nullptr), std::logic_error);
 }
 
 TEST(FBString, testFixedBugs) {
 }
 
 TEST(FBString, testFixedBugs) {
index 0874a8f2f8e6c05ed168f8474a1f257091f4a58f..1839903634db71696d0e13c4b9e13389ee746083 100644 (file)
@@ -348,7 +348,7 @@ TEST(MPMCQueue, mt_try_enq_deq_deterministic) {
 
 uint64_t nowMicro() {
   timeval tv;
 
 uint64_t nowMicro() {
   timeval tv;
-  gettimeofday(&tv, 0);
+  gettimeofday(&tv, nullptr);
   return static_cast<uint64_t>(tv.tv_sec) * 1000000 + tv.tv_usec;
 }
 
   return static_cast<uint64_t>(tv.tv_sec) * 1000000 + tv.tv_usec;
 }