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 static if(is(T:B)){
  11. return func(t.y);
  12. }else static 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. }
Success #stdin #stdout 0.01s 2120KB
stdin
Standard input is empty
stdout
0
0
0