mirror of
https://github.com/RPCSX/rpcsx.git
synced 2026-04-04 14:08:37 +00:00
IdManager.h: Improvements
* Ensure ::PtrSame<T, Derived> is true. * Allow id_base, id_step and id_count to be of enumeration type. * Fix potential deadlock in kernel explorer. idm::select: * Allow to select multiple inherited object types for idm::select. * Allow function reference types. (they don't allow access to operator() directly, use deducing std::function constructor instead) * Ensure ::is_same_ptr<T, object_type> is true.
This commit is contained in:
parent
69ceebeb05
commit
71e07dc6c7
6 changed files with 80 additions and 147 deletions
|
|
@ -1039,7 +1039,7 @@ concept PtrCastable = requires(const volatile X* x, const volatile Y* y)
|
|||
};
|
||||
|
||||
template <typename X, typename Y> requires PtrCastable<X, Y>
|
||||
constexpr bool is_same_ptr()
|
||||
consteval bool is_same_ptr()
|
||||
{
|
||||
if constexpr (std::is_void_v<X> || std::is_void_v<Y> || std::is_same_v<std::remove_cv_t<X>, std::remove_cv_t<Y>>)
|
||||
{
|
||||
|
|
@ -1051,33 +1051,24 @@ constexpr bool is_same_ptr()
|
|||
}
|
||||
else
|
||||
{
|
||||
if (std::is_constant_evaluated())
|
||||
bool result = false;
|
||||
|
||||
if constexpr (sizeof(X) < sizeof(Y))
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
if constexpr (sizeof(X) < sizeof(Y))
|
||||
{
|
||||
std::allocator<Y> a{};
|
||||
Y* ptr = a.allocate(1);
|
||||
result = static_cast<X*>(ptr) == static_cast<void*>(ptr);
|
||||
a.deallocate(ptr, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::allocator<X> a{};
|
||||
X* ptr = a.allocate(1);
|
||||
result = static_cast<Y*>(ptr) == static_cast<void*>(ptr);
|
||||
a.deallocate(ptr, 1);
|
||||
}
|
||||
|
||||
return result;
|
||||
std::allocator<Y> a{};
|
||||
Y* ptr = a.allocate(1);
|
||||
result = static_cast<X*>(ptr) == static_cast<void*>(ptr);
|
||||
a.deallocate(ptr, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::aligned_union_t<0, X, Y> s;
|
||||
Y* ptr = reinterpret_cast<Y*>(&s);
|
||||
return static_cast<X*>(ptr) == static_cast<void*>(ptr);
|
||||
std::allocator<X> a{};
|
||||
X* ptr = a.allocate(1);
|
||||
result = static_cast<Y*>(ptr) == static_cast<void*>(ptr);
|
||||
a.deallocate(ptr, 1);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue