Revert D4832473: [Folly] Disable EnvUtil::setAsCurrentEnvironment() on platforms...
[folly.git] / folly / experimental / ReadMostlySharedPtr.h
index f81ce856a6b962dd080887318ccad71b539776f1..580152ac49af62f9d5acab1d232420ba8ce84566 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2016 Facebook, Inc.
+ * Copyright 2017 Facebook, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -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);
+}
 }