Код: Выделить всё
#include
struct Base { int x; };
struct Derived : Base {};
static_assert(std::is_standard_layout_v);
static_assert(sizeof(Base[2]) == sizeof(Derived[2]));
int main() {
Derived a[3];
Base* b = a;
b = b + 2; // is this valid?
}
< /code>
[expr.add]также [expr.add] говорит: «Если выражения p имеют тип« для добавления [...], если выражение p имеет тип pv at a a wry whip -lection, а не Arr -lection, где Traver the not the foreme this the not the fore not the forement the not the fore not the forement the not the foremet loge the foremay Неопределенный ".
и« аналогичный »определяется в [conv.qual] :« Два типа T1 и T2 похожи, если [...], а типы, обозначенные U, одинаковы. »
, очевидно, это не так, как это не так, для Iterate с опорой для базового класса,
, но может быть стандартным, чтобы быть стандартным. /> или стандартный лайт только для профсоюзов? < /p>
Подробнее здесь: https://stackoverflow.com/questions/796 ... base-class
Мобильная версия