fork download
  1. import std.stdio;
  2.  
  3. struct A{int x;}
  4. struct B{C y;}
  5. struct C{int z;}
  6.  
  7. int func(T)(T t){
  8. static if(is(T:A)){
  9. return t.x;
  10. }else if(is(T:B)){
  11. return func(t.y);
  12. }else if(is(T:C)){
  13. return t.z;
  14. }
  15. }
  16.  
  17. void main()
  18. {
  19. writeln(func(new A));
  20. writeln(func(new B));
  21. writeln(func(new C));
  22. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.d(11): Error: no property 'y' for type 'A', did you mean 'x'?
stdout
Standard output is empty