Comment #0 by stanislav.blinov — 2021-10-25T14:00:53Z
struct Storage(T) {
T[1] items;
this(T[] arr) { // Error: field `items` must be initialized in constructor, because it is nested struct
/* ... */
}
}
void test() {
struct Cat {
~this() {} // nested
}
struct Box {
Cat cat;
}
//static assert(__traits(isNested, Box)); // would fail if uncommented
Storage!Box storage;
}
---
Cat is nested. Box contains Cat, has no explicitly defined methods, but does have __xdtor due to Cat. Does not appear as a nested struct through __traits, but stumps Storage's ctor "because it is nested struct".
Comment #1 by robert.schadek — 2024-12-13T19:18:50Z