/*
- * 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.
std::shared_ptr<T> ptr_;
};
-}
+} // namespace detail
template <typename T, typename RefCount = DefaultRefCount>
class ReadMostlyMainPtr {
}
}
- std::shared_ptr<T> getStdShared() {
+ std::shared_ptr<T> getStdShared() const {
if (impl_) {
- return impl_->ptr_;
+ return impl_->getShared();
} else {
return {};
}
std::shared_ptr<T> getStdShared() const {
if (impl_) {
- return impl_->ptr_;
+ return impl_->getShared();
} else {
return {};
}
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