summaryrefslogtreecommitdiffhomepage
path: root/compat/borrowed-ptr-cast.hpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2024-07-14 17:01:46 +0200
committerStanislaw Halik <sthalik@misaki.pl>2024-07-14 17:17:45 +0200
commit25057f99ac871684695175738f9ac31890bb4bba (patch)
treefc482b9077032ae8ae2c973a0085dc2824c9a3c3 /compat/borrowed-ptr-cast.hpp
parentb47f6164b82c166afb6d560caa3ffb79db15c7b7 (diff)
w
Diffstat (limited to 'compat/borrowed-ptr-cast.hpp')
-rw-r--r--compat/borrowed-ptr-cast.hpp38
1 files changed, 0 insertions, 38 deletions
diff --git a/compat/borrowed-ptr-cast.hpp b/compat/borrowed-ptr-cast.hpp
deleted file mode 100644
index 18f0a50e..00000000
--- a/compat/borrowed-ptr-cast.hpp
+++ /dev/null
@@ -1,38 +0,0 @@
-#pragma once
-#include "borrowed-ptr-fwd.hpp"
-#include "compat/assert.hpp"
-
-namespace floormat::detail_borrowed_ptr {
-
-//static_assert(std::is_same_v<T, U> || std::has_virtual_destructor_v<T> && std::has_virtual_destructor_v<T>); // todo! for simple_bptr
-
-template<typename From, typename To>
-concept StaticCastable = requires(From* from) {
- static_cast<To*>(from);
-};
-
-} // namespace floormat::detail_borrowed_ptr
-
-namespace floormat {
-
-template<typename To, typename From>
-bptr<To> static_pointer_cast(const bptr<From>& p) noexcept
-{
- // hack to generate better error message
- if constexpr (detail_borrowed_ptr::StaticCastable<From, To>)
- {
- if (p.blk && p.blk->_ptr) [[likely]]
- return bptr<To>{p, nullptr};
- }
- else
- {
- using detail_borrowed_ptr::StaticCastable;
- // concepts can't be forward-declared so use static_assert
- static_assert(StaticCastable<From, To>,
- "cannot static_cast, classes must be related by inheritance");
- }
-
- return bptr<To>{nullptr};
-}
-
-} // namespace floormat