diff options
Diffstat (limited to 'compat/borrowed-ptr-fwd.hpp')
-rw-r--r-- | compat/borrowed-ptr-fwd.hpp | 25 |
1 files changed, 7 insertions, 18 deletions
diff --git a/compat/borrowed-ptr-fwd.hpp b/compat/borrowed-ptr-fwd.hpp index e773a089..df985fd7 100644 --- a/compat/borrowed-ptr-fwd.hpp +++ b/compat/borrowed-ptr-fwd.hpp @@ -1,22 +1,13 @@ #pragma once -namespace floormat::detail_borrowed_ptr { - -struct control_block_; - -template<typename From, typename To> -concept StaticCastable = requires(From* ptr) { - static_cast<To*>(ptr); -}; - -} // namespace floormat::detail_borrowed_ptr +namespace floormat::detail_borrowed_ptr { struct control_block_; } namespace floormat { template<typename T> class bptr final // NOLINT(*-special-member-functions) { - T* ptr; // todo add simple_bptr that doesn't allow casting. should only have the control block member variable. + mutable T* ptr; detail_borrowed_ptr::control_block_* blk; explicit constexpr bptr(NoInitT) noexcept; @@ -37,17 +28,15 @@ public: template<typename Y> requires std::is_convertible_v<Y*, T*> bptr& operator=(const bptr<Y>&) noexcept; template<typename Y> requires std::is_convertible_v<Y*, T*> bptr& operator=(bptr<Y>&&) noexcept; - void swap() noexcept; - T* get() noexcept; - const T* get() const noexcept; - T& operator*() const noexcept; - T* operator->() const noexcept; + void swap(bptr& other) noexcept; + constexpr T* get() const noexcept; + constexpr T& operator*() const noexcept; + constexpr T* operator->() const noexcept; uint32_t use_count() const noexcept; explicit operator bool() const noexcept; template<typename U> friend class bptr; - template<typename Tʹ, typename U> - friend bptr<U> static_pointer_cast(const bptr<Tʹ>& p) noexcept; + template<typename Tʹ, typename U> friend bptr<U> static_pointer_cast(const bptr<Tʹ>& p) noexcept; }; } // namespace floormat |