Код: Выделить всё
struct A {
int n;
double d;
};
int main() {
auto a = A{.n = 1, .d = 3.14};
// error: static_cast from 'int*' to 'A*' is not allowed
auto _ = static_cast(&a.n);
}
[*]they are the same object, or
[*]one is a union object and the other is a non-static data member of that object, or
[*]one is a standard-layout class object and the other is the first non-static data member of that object or any base class Subobject этого объекта, или
Существует объект C, такой, что A и C являются InterConceptible, а C и B
interConceptible. pointer-interconvertible , так почему же static_cast (& a.n) плохо сформирован?
Подробнее здесь: https://stackoverflow.com/questions/796 ... uch-a-case