A code fragment using static foreach

https://forum.dlang.org/thread/jiefcxwqbjzqnmtaz...@forum.dlang.org#post-beruryblsptnunsowjph:40forum.dlang.org

does not compile with the current GDC (GCC 4.9.4 and 5.5.0). I tried to encapsulate this code into a version block but GDC still checks the syntax. Is there any more elegant way besides of using a mixin?:

   version (DigitalMars) {
      pragma (msg, "DMD");
      mixin (`
enum typenames = ["float", "double", "real", "short", "int", "long"];
      static foreach (s; typenames) {
         pragma (msg, s);
         disp[s] = mixin ("&mymain!" ~ s);
      }
      `);
   }

Reply via email to