fork download
  1. import std.stdio;
  2. import std.typetuple;
  3.  
  4. class A {
  5. static const int value = 3;
  6. };
  7.  
  8. class B {
  9. static const int value = 4;
  10. };
  11.  
  12.  
  13. pure auto getValue(D, T...)() if (staticIndexOf!(D, T) > -1) {
  14. return T[staticIndexOf!(D, T)].value;
  15. }
  16.  
  17. int main() {
  18. static assert(getValue!(B, A, B) == 4);
  19.  
  20. writeln(getValue!(A, A, B));
  21.  
  22. return 0;
  23. }
Success #stdin #stdout 0.01s 2120KB
stdin
Standard input is empty
stdout
3