Wrapper around a recursive data type

drug007 drug2004 at bk.ru
Sun Jul 14 12:21:24 UTC 2024


On 09.07.2024 06:54, Steven Schveighoffer wrote:
> On Monday, 8 July 2024 at 08:56:51 UTC, drug007 wrote:
>> How can I "break" this recursion or some other work around to fix it?
> 
> A few ideas:
> 
> 1. If it's immediately recursive (that is, contains a pointer to 
> itself), just use the type itself somehow. You may not be able to do 
> this with recursive templates.
> 2. If the data itself is static, and not actually containing different 
> things, defer the construction of the Meta members until needed. In 
> other words, make them structs with a member which accesses the meta 
> when requested.
> 3. In a project I have which constructs a parallel type on existing 
> types, I use `opDispatch` to defer instantiation of the members until 
> later. This may or may not work for you depending on the use case (you 
> can't introspect `opDispatch`).
> 
> -Steve

Decided to use untyped array (like void[]) and then a decorator to make 
it typed one. It seems to be working, testing in progress.



More information about the Digitalmars-d-learn mailing list