mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-09 00:11:24 +12:00
shared_ptr.hpp: don't use fake objects
This lifts the limitation for casting with abstract classes. Use new C++20 feature (constexpr allocator) to test viability. Add SamePtr concept to types.hpp
This commit is contained in:
parent
eec9578619
commit
f5e529db61
4 changed files with 130 additions and 149 deletions
|
@ -11,3 +11,52 @@ static_assert(be_t<u16>(1) + be_t<u32>(2) + be_t<u64>(3) == 6);
|
|||
static_assert(le_t<u16>(1) + le_t<u32>(2) + le_t<u64>(3) == 6);
|
||||
|
||||
static_assert(sizeof(nullptr) == sizeof(void*));
|
||||
|
||||
static_assert(__cpp_constexpr_dynamic_alloc >= 201907L);
|
||||
|
||||
namespace
|
||||
{
|
||||
struct A
|
||||
{
|
||||
int a;
|
||||
};
|
||||
|
||||
struct B : A
|
||||
{
|
||||
int b;
|
||||
};
|
||||
|
||||
struct Z
|
||||
{
|
||||
};
|
||||
|
||||
struct C
|
||||
{
|
||||
virtual ~C() = 0;
|
||||
int C;
|
||||
};
|
||||
|
||||
struct D : Z, B
|
||||
{
|
||||
int d;
|
||||
};
|
||||
|
||||
struct E : C, B
|
||||
{
|
||||
int e;
|
||||
};
|
||||
|
||||
struct F : C
|
||||
{
|
||||
virtual ~F() = 0;
|
||||
};
|
||||
|
||||
static_assert(is_same_ptr<B, A>());
|
||||
static_assert(is_same_ptr<A, B>());
|
||||
static_assert(is_same_ptr<D, B>());
|
||||
static_assert(is_same_ptr<B, D>());
|
||||
static_assert(!is_same_ptr<E, B>());
|
||||
static_assert(!is_same_ptr<B, E>());
|
||||
static_assert(is_same_ptr<F, C>());
|
||||
static_assert(is_same_ptr<C, F>());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue