Skip to content

Commit

Permalink
refactor: refactoring NonOwnerPointer
Browse files Browse the repository at this point in the history
  • Loading branch information
OEOTYAN committed Jan 16, 2024
1 parent 91e5ccb commit 3c77504
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/mc/deps/core/common/bedrock/NonOwnerPointer.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ class NonOwnerPointer {
std::shared_ptr<Bedrock::EnableNonOwnerReferences::ControlBlock> mControlBlock;
NonOwnerPointer(std::nullptr_t) noexcept {} // NOLINT
T* get() const { return reinterpret_cast<T*>(mControlBlock.get()); }
explicit operator bool() const noexcept { return get() != nullptr; }
explicit operator bool() const noexcept { return mControlBlock; }

[[nodiscard]] constexpr operator T*() const { return get(); }
[[nodiscard]] constexpr T* operator->() const { return get(); }
[[nodiscard]] constexpr decltype(auto) operator*() const { return *get(); }
[[nodiscard]] constexpr operator T*() const { return get(); }
[[nodiscard]] constexpr T* operator->() const { return get(); }
[[nodiscard]] constexpr T& operator*() const { return *get(); }
};

template <class T>
Expand All @@ -35,5 +35,4 @@ template <class T1, class T2>
[[nodiscard]] std::strong_ordering operator<=>(NonOwnerPointer<T1> const& l, NonOwnerPointer<T2> const& r) noexcept {
return l.get() <=> r.get();
}

}; // namespace Bedrock

0 comments on commit 3c77504

Please sign in to comment.