How to do a static assert that a pointer cast is trivial?
问题 Let's say I have these types: struct A { int a; }; struct B { int b; }; struct C : public A, public B { int c; }; A C* pointer can be cast to A* pointer without adjusting the actual address at all. But when C* is cast to B* , the value must change. I'd like to ensure that two related types I have can be cast to each other without a change in address (i.e. that there is no multiple inheritance, or that the base class is the first base of the derived class). This could be checked at run-time, e