summaryrefslogtreecommitdiffhomepage
path: root/compat/borrowed-ptr.hpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2024-07-16 12:23:50 +0200
committerStanislaw Halik <sthalik@misaki.pl>2024-07-16 12:23:50 +0200
commit6aabc74a535da1f2d5cf866346b31939d097cbac (patch)
tree660e7af579526a4f7b85df206cd68a45039a3ab4 /compat/borrowed-ptr.hpp
parenteba565a6359957a7ba5c3af645af36eefd58fbf3 (diff)
w
Diffstat (limited to 'compat/borrowed-ptr.hpp')
-rw-r--r--compat/borrowed-ptr.hpp24
1 files changed, 13 insertions, 11 deletions
diff --git a/compat/borrowed-ptr.hpp b/compat/borrowed-ptr.hpp
index 62394087..7ab42ebb 100644
--- a/compat/borrowed-ptr.hpp
+++ b/compat/borrowed-ptr.hpp
@@ -24,25 +24,24 @@ struct control_block final
static void weak_decrement(control_block*& blk) noexcept;
};
+#if 0
template<typename From, typename To>
-concept StaticCastable = requires(From* from) {
+concept StaticCastable = requires(From* from, To* to) {
static_cast<To*>(from);
- requires std::is_base_of_v<std::remove_cvref_t<From>, std::remove_cvref_t<To>>;
+ static_cast<const bptr_base*>(from);
+ static_cast<const bptr_base*>(to);
};
template<typename From, typename To>
-concept DerivedFrom = requires(From* x) {
-#if 0
+concept DerivedFrom = requires(From* from, To* to) {
+ static_cast<const bptr_base*>(from);
+ static_cast<const bptr_base*>(to);
requires std::is_convertible_v<From*, To*>;
- requires std::is_convertible_v<From*, const bptr_base*>;
- requires std::is_convertible_v<To*, const bptr_base*>;
- requires std::is_base_of_v<bptr_base, From>;
- requires std::is_base_of_v<bptr_base, To>;
- requires std::is_base_of_v<std::remove_cvref_t<To>, std::remove_cvref_t<From>>;
+};
#else
- static_cast<To*>(std::declval<From*>());
+template<typename From, typename To> concept DerivedFrom = true;
+template<typename From, typename To> concept StaticCastable = true;
#endif
-};
} // namespace floormat::detail_bptr
@@ -103,6 +102,9 @@ public:
explicit operator bool() const noexcept;
bool operator==(const bptr<const T>& other) const noexcept;
+ bool operator==(const bptr<T>& other) const noexcept requires (!std::is_const_v<T>);
+ bool operator==(const std::nullptr_t& other) const noexcept;
+
std::strong_ordering operator<=>(const bptr<const T>& other) const noexcept;
template<typename U> friend class bptr;