#pragma once #include "borrowed-ptr-fwd.hpp" namespace floormat::detail_borrowed_ptr { struct control_block; template concept DerivedFrom = requires(From* x) { requires !std::is_same_v; requires std::is_nothrow_convertible_v; }; } // namespace floormat::detail_borrowed_ptr namespace floormat { template class bptr; template class bptr final // NOLINT(*-special-member-functions) { mutable T* casted_ptr; detail_borrowed_ptr::control_block* blk; explicit bptr(DirectInitT, T* casted_ptr, detail_borrowed_ptr::control_block* blk) noexcept; struct private_tag_t final {}; static constexpr private_tag_t private_tag{}; template bptr(const bptr& other, private_tag_t) noexcept; template bptr& _copy_assign(const bptr& other) noexcept; template bptr(bptr&& other, private_tag_t) noexcept; template bptr& _move_assign(bptr&& other) noexcept; public: template requires std::is_constructible_v explicit bptr(InPlaceInitT, Ts&&... args) noexcept; explicit bptr(T* ptr) noexcept; bptr() noexcept; ~bptr() noexcept; bptr(std::nullptr_t) noexcept; // NOLINT(*-explicit-conversions) bptr& operator=(std::nullptr_t) noexcept; bptr(const bptr&) noexcept; bptr& operator=(const bptr&) noexcept; template Y> bptr(const bptr&) noexcept; template Y> bptr& operator=(const bptr&) noexcept; bptr(bptr&&) noexcept; bptr& operator=(bptr&&) noexcept; template Y> bptr(bptr&&) noexcept; template Y> bptr& operator=(bptr&&) noexcept; void reset() noexcept; template void destroy() noexcept; void swap(bptr& other) noexcept; uint32_t use_count() const noexcept; T* get() const noexcept; T* operator->() const noexcept; T& operator*() const noexcept; explicit operator bool() const noexcept; friend bool operator==(const bptr& a, const bptr& b) noexcept; template friend class bptr; template friend bptr static_pointer_cast(const bptr& p) noexcept; }; } // namespace floormat