11 std::shared_ptr<::Bedrock::EnableNonOwnerReferences::ControlBlock> mControlBlock;
14 NonOwnerPointer(std::shared_ptr<::Bedrock::EnableNonOwnerReferences::ControlBlock> cb, T* p)
15 : mControlBlock(std::move(cb)),
18 template <
typename U = T>
19 requires std::is_convertible_v<U*, T*>
20 NonOwnerPointer(U
const& t)
23 const_cast<T*
>(std::addressof(t))
25 template <
typename U = T>
26 requires std::is_convertible_v<U*, T*>
27 NonOwnerPointer(NonOwnerPointer<U>
const& p) : NonOwnerPointer(p.mControlBlock, p.mPointer) {}
28 template <
typename U = T>
29 requires std::is_convertible_v<U*, T*>
30 NonOwnerPointer(NonOwnerPointer<U>&& p)
31 : NonOwnerPointer(std::move(p.mControlBlock), std::exchange(p.mPointer,
nullptr)) {}
34 NonOwnerPointer()
noexcept {}
35 NonOwnerPointer(std::nullptr_t)
noexcept {}
37 if (mControlBlock && mControlBlock->mIsValid) {
42 explicit operator bool()
const noexcept {
return get() !=
nullptr; }
44 [[nodiscard]]
constexpr operator T*()
const {
return get(); }
45 [[nodiscard]]
constexpr T* operator->()
const {
return get(); }
46 [[nodiscard]]
constexpr T& operator*()
const {
return *get(); }
48 [[nodiscard]]
bool operator==(nullptr_t)
noexcept {
return get() ==
nullptr; }
50 [[nodiscard]]
bool operator==(NonOwnerPointer<U>
const& r)
noexcept {
51 return get() == r.get();
54 [[nodiscard]]
bool operator<=>(NonOwnerPointer<U>
const& r)
noexcept {
55 return get() <=> r.get();