Staticcast vs reinterpret_cast check in statement

I saw the code line by line

ASSERT(static_cast<MyClass*>(p) == reinterpret_cast<MyClass*>(p))

I think p was a pointer to the base type. What is the purpose of this statement? Is it a test that MyClass is not part of any multiple inheritance hierarchy (or anything that causes a famous actor to change the value of p)?

+4
source share
1 answer

reinterpret_cast<T*>(p) , , reinterpret_cast<T*>(p) , , , . reinterpret_cast , , , .

static_cast<T*>(p), . , static_cast<T*>(p) , p T* p, [] ( void*). , static_cast<T*>(p) . , .

, , . , , , reinterpret_cast<T*>(p), , . , , , .

, ASSERT() : " !"

+2

All Articles