Mutually recursive template expansion

Stephen stephen.personal27 at gmail.com
Fri Oct 1 14:03:06 UTC 2021


I've been trying out templates in more depth and one thing I was 
wondering was whether template expansions with circular 
dependencies might work.
Here is an example that doesn't work:
```d
mixin(A!());
mixin(B!());

void main() {}

template A() {
     const char[] A = q{
         struct Ar {
             Br b;
         }
     };
}

template B() {
     const char[] B = q{
         struct Br {
             Ar a;
         }
     };
}
```
This code should work should mutual recursion be supported. How 
might I get it to work properly (without sacrificing recursion or 
templates)?


More information about the Digitalmars-d-learn mailing list