From 5798acdb8cad0c8af2bf5fdb387234a5932ec17d Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 4 May 2024 12:59:49 +0200 Subject: wip bptr --- compat/borrowed-ptr.hpp | 5 ++++- compat/borrowed-ptr.inl | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/compat/borrowed-ptr.hpp b/compat/borrowed-ptr.hpp index f649cae3..10b95be9 100644 --- a/compat/borrowed-ptr.hpp +++ b/compat/borrowed-ptr.hpp @@ -14,7 +14,7 @@ class bptr final // NOLINT(*-special-member-functions) T* ptr; // todo add simple_bptr that doesn't allow casting. should only have the control block element. detail_borrowed_ptr::control_block_* blk; - friend bptr static_pointer_cast(const bptr& p); + constexpr bptr(NoInitT) noexcept; public: template @@ -38,8 +38,11 @@ public: T* operator->() const noexcept; uint32_t use_count() const noexcept; explicit operator bool() const noexcept; + + friend bptr static_pointer_cast(const bptr& p); }; +template constexpr bptr::bptr(NoInitT) noexcept {}; template constexpr bptr::bptr(std::nullptr_t) noexcept: ptr{nullptr}, blk{nullptr} {} template constexpr bptr::bptr() noexcept: bptr{nullptr} {} diff --git a/compat/borrowed-ptr.inl b/compat/borrowed-ptr.inl index 1d0ac7b6..7302c857 100644 --- a/compat/borrowed-ptr.inl +++ b/compat/borrowed-ptr.inl @@ -141,7 +141,7 @@ bptr& bptr::operator=(bptr&& other) noexcept template bptr static_pointer_cast(const bptr& p) { - auto ret = bptr{}; + auto ret = bptr{NoInit}; ret.blk = p.blk; if (ret.blk) [[likely]] ret.blk->incr(); -- cgit v1.2.3