summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2024-05-04 23:23:38 +0200
committerStanislaw Halik <sthalik@misaki.pl>2024-05-05 03:31:20 +0200
commit9f13bacf281aa07da04c9709b62fe0dead21b2c8 (patch)
tree1b492b7a4c319b795d841df9c38cadb56d6d473f
parent92d60403f3de094dc2d040a7fce869a5bb60695a (diff)
a w
-rw-r--r--compat/borrowed-ptr.inl9
1 files changed, 5 insertions, 4 deletions
diff --git a/compat/borrowed-ptr.inl b/compat/borrowed-ptr.inl
index 98e0fec5..6b72192c 100644
--- a/compat/borrowed-ptr.inl
+++ b/compat/borrowed-ptr.inl
@@ -92,7 +92,7 @@ bptr<T>::bptr(T* ptr) noexcept:
casted_ptr{ptr},
blk{detail_borrowed_ptr::control_block_impl<T>::create(ptr)}
{
- fm_bptr_assert(blk && blk->_count == 1 && ptr && blk->_ptr);
+ fm_bptr_assert(!blk || blk->_count == 1 && blk->_ptr);
}
template<typename T>
@@ -142,8 +142,9 @@ template<typename T>
template<bool MaybeEmpty>
void bptr<T>::destroy() noexcept
{
- if constexpr(!MaybeEmpty)
- fm_assert(blk);
+ if constexpr(MaybeEmpty)
+ if (!blk)
+ return;
blk->free_ptr();
blk->_ptr = nullptr;
casted_ptr = nullptr;
@@ -219,7 +220,7 @@ template<typename T> T* bptr<T>::operator->() const noexcept
}
template<typename T> T& bptr<T>::operator*() const noexcept { return *operator->(); }
-template<typename T> bool operator==(const bptr<T>& a, const bptr<T>& b) noexcept { return a.blk == b.blk; }
+template<typename T> bool operator==(const bptr<T>& a, const bptr<T>& b) noexcept { return a.get() == b.get(); }
template<typename T> bptr<T>::operator bool() const noexcept { return get(); }
template<typename T>