summaryrefslogtreecommitdiffhomepage
path: root/compat/borrowed-ptr.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'compat/borrowed-ptr.hpp')
-rw-r--r--compat/borrowed-ptr.hpp50
1 files changed, 16 insertions, 34 deletions
diff --git a/compat/borrowed-ptr.hpp b/compat/borrowed-ptr.hpp
index 6b1dcdf4..28d35b8f 100644
--- a/compat/borrowed-ptr.hpp
+++ b/compat/borrowed-ptr.hpp
@@ -1,7 +1,7 @@
#pragma once
#include "borrowed-ptr-fwd.hpp"
-namespace floormat::detail_borrowed_ptr {
+namespace floormat::detail_bptr {
struct control_block;
@@ -12,11 +12,10 @@ concept StaticCastable = requires(From* from) {
template<typename From, typename To>
concept DerivedFrom = requires(From* x) {
- !std::is_same_v<From, To>;
std::is_convertible_v<From*, To*>;
};
-} // namespace floormat::detail_borrowed_ptr
+} // namespace floormat::detail_bptr
namespace floormat {
@@ -33,47 +32,30 @@ struct bptr_base
template<typename T>
class bptr final // NOLINT(*-special-member-functions)
{
- detail_borrowed_ptr::control_block* blk;
-
- template<typename Y>
- requires std::is_convertible_v<T*, const bptr_base*>
- bptr(const bptr<Y>& other, std::nullptr_t) noexcept;
-
- template<typename Y>
- requires std::is_convertible_v<T*, const bptr_base*>
- bptr(bptr<Y>&& other, std::nullptr_t) noexcept;
+ detail_bptr::control_block* blk;
+ template<typename Y> bptr(const bptr<Y>& other, std::nullptr_t) noexcept;
+ template<typename Y> bptr(bptr<Y>&& other, std::nullptr_t) noexcept;
template<typename Y> bptr& _copy_assign(const bptr<Y>& other) noexcept;
template<typename Y> bptr& _move_assign(bptr<Y>&& other) noexcept;
public:
template<typename... Ts>
- requires (std::is_constructible_v<std::remove_const_t<T>, Ts&&...> && std::is_convertible_v<T*, const bptr_base*>)
+ requires std::is_constructible_v<std::remove_const_t<T>, Ts&&...>
explicit bptr(InPlaceInitT, Ts&&... args) noexcept;
- explicit bptr(T* ptr) noexcept requires std::is_convertible_v<T*, const bptr_base*>;
- bptr() noexcept requires std::is_convertible_v<T*, const bptr_base*>;
+ explicit bptr(T* ptr) noexcept requires std::is_convertible_v<const T*, const bptr_base*>;
+ bptr() noexcept;
~bptr() noexcept;
- bptr(std::nullptr_t) noexcept requires std::is_convertible_v<T*, const bptr_base*>; // NOLINT(*-explicit-conversions)
- bptr& operator=(std::nullptr_t) noexcept requires std::is_convertible_v<T*, const bptr_base*>;
-
- bptr(const bptr&) noexcept requires std::is_convertible_v<T*, const bptr_base*>;
- bptr& operator=(const bptr&) noexcept requires std::is_convertible_v<T*, const bptr_base*>;
-
- template<detail_borrowed_ptr::DerivedFrom<T> Y> bptr(const bptr<Y>&) noexcept
- requires std::is_convertible_v<T*, const bptr_base*>;
-
- template<detail_borrowed_ptr::DerivedFrom<T> Y> bptr& operator=(const bptr<Y>&) noexcept
- requires std::is_convertible_v<T*, const bptr_base*>;
+ bptr(std::nullptr_t) noexcept; // NOLINT(*-explicit-conversions)
+ bptr& operator=(std::nullptr_t) noexcept;
- bptr(bptr&&) noexcept requires std::is_convertible_v<T*, const bptr_base*>;
- bptr& operator=(bptr&&) noexcept requires std::is_convertible_v<T*, const bptr_base*>;
+ template<detail_bptr::DerivedFrom<T> Y> bptr(const bptr<Y>&) noexcept;
+ template<detail_bptr::DerivedFrom<T> Y> bptr& operator=(const bptr<Y>&) noexcept;
- template<detail_borrowed_ptr::DerivedFrom<T> Y> bptr(bptr<Y>&&) noexcept
- requires std::is_convertible_v<T*, const bptr_base*>;
- template<detail_borrowed_ptr::DerivedFrom<T> Y> bptr& operator=(bptr<Y>&&) noexcept
- requires std::is_convertible_v<T*, const bptr_base*>;
+ template<detail_bptr::DerivedFrom<T> Y> bptr(bptr<Y>&&) noexcept;
+ template<detail_bptr::DerivedFrom<T> Y> bptr& operator=(bptr<Y>&&) noexcept;
void reset() noexcept;
void destroy() noexcept;
@@ -91,12 +73,12 @@ public:
template<typename U> friend class bptr;
template<typename To, typename From>
- requires (std::is_convertible_v<To*, const bptr_base*> && detail_borrowed_ptr::StaticCastable<From, To>)
+ requires detail_bptr::StaticCastable<From, To>
friend bptr<To> static_pointer_cast(const bptr<From>& p) noexcept;
};
template<typename To, typename From>
-requires (std::is_convertible_v<To*, const bptr_base*> && detail_borrowed_ptr::StaticCastable<From, To>)
+requires detail_bptr::StaticCastable<From, To>
bptr<To> static_pointer_cast(const bptr<From>& p) noexcept
{
if (p.blk && p.blk->_ptr) [[likely]]