Wrapper around a recursive data type
Steven Schveighoffer
schveiguy at gmail.com
Tue Jul 9 03:39:49 UTC 2024
On Monday, 8 July 2024 at 13:29:05 UTC, user1234 wrote:
> On Monday, 8 July 2024 at 08:56:51 UTC, drug007 wrote:
>> I need to generate some meta info of my data types. I do it
>> this [...]
>> How can I "break" this recursion or some other work around to
>> fix it?
>
> Use `Node*[]` for the children type. That way the compiler
> knows the size of the (previously) problematic member. In other
> words, instead of the need to know `Node` size, the compiler
> will not look further, it's a pointer.
This isn't the issue exactly. `Node[]` is a pointer as well.
The issue is that the template recursively depends on itself.
You would run into the same issue if the template recursed on the
type of the pointed-at value.
-Steve
More information about the Digitalmars-d-learn
mailing list