Fix copyright lines
[folly.git] / folly / experimental / ReadMostlySharedPtr.h
index f81ce856a6b962dd080887318ccad71b539776f1..0745ee4adf59e7e88b9f7c94f2dd054176c6e4c3 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2016 Facebook, Inc.
+ * Copyright 2015-present Facebook, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -94,7 +94,7 @@ class ReadMostlySharedPtrCore {
   std::shared_ptr<T> ptr_;
 };
 
-}
+} // namespace detail
 
 template <typename T, typename RefCount = DefaultRefCount>
 class ReadMostlyMainPtr {
@@ -159,9 +159,9 @@ class ReadMostlyMainPtr {
     }
   }
 
-  std::shared_ptr<T> getStdShared() {
+  std::shared_ptr<T> getStdShared() const {
     if (impl_) {
-      return impl_->ptr_;
+      return impl_->getShared();
     } else {
       return {};
     }
@@ -320,7 +320,7 @@ class ReadMostlySharedPtr {
 
   std::shared_ptr<T> getStdShared() const {
     if (impl_) {
-      return impl_->ptr_;
+      return impl_->getShared();
     } else {
       return {};
     }
@@ -395,4 +395,60 @@ class ReadMostlyMainPtrDeleter {
   std::vector<RefCount*> refCounts_;
   std::vector<folly::Function<void()>> decrefs_;
 };
+
+template <typename T, typename RefCount>
+inline bool operator==(
+    const ReadMostlyMainPtr<T, RefCount>& ptr,
+    std::nullptr_t) {
+  return ptr.get() == nullptr;
+}
+
+template <typename T, typename RefCount>
+inline bool operator==(
+    std::nullptr_t,
+    const ReadMostlyMainPtr<T, RefCount>& ptr) {
+  return ptr.get() == nullptr;
+}
+
+template <typename T, typename RefCount>
+inline bool operator==(
+    const ReadMostlySharedPtr<T, RefCount>& ptr,
+    std::nullptr_t) {
+  return ptr.get() == nullptr;
+}
+
+template <typename T, typename RefCount>
+inline bool operator==(
+    std::nullptr_t,
+    const ReadMostlySharedPtr<T, RefCount>& ptr) {
+  return ptr.get() == nullptr;
+}
+
+template <typename T, typename RefCount>
+inline bool operator!=(
+    const ReadMostlyMainPtr<T, RefCount>& ptr,
+    std::nullptr_t) {
+  return !(ptr == nullptr);
+}
+
+template <typename T, typename RefCount>
+inline bool operator!=(
+    std::nullptr_t,
+    const ReadMostlyMainPtr<T, RefCount>& ptr) {
+  return !(ptr == nullptr);
+}
+
+template <typename T, typename RefCount>
+inline bool operator!=(
+    const ReadMostlySharedPtr<T, RefCount>& ptr,
+    std::nullptr_t) {
+  return !(ptr == nullptr);
+}
+
+template <typename T, typename RefCount>
+inline bool operator!=(
+    std::nullptr_t,
+    const ReadMostlySharedPtr<T, RefCount>& ptr) {
+  return !(ptr == nullptr);
 }
+} // namespace folly