On Saturday, 12 October 2013 at 11:50:05 UTC, Artur Skawina wrote:
On 10/12/13 13:42, Artur Skawina wrote:
   template isBaseOf(BASE, C) {
      static if (is(C S == super))
         enum isBaseOf = {
            foreach (A; S)
               static if (is(A==BASE))
                  return true;
            return is(C==BASE);
         }();
      else
         enum isBaseOf = is(C==BASE);
   }

That was too verbose.

   template isBaseOf(BASE, C) {
      enum isBaseOf = {
         static if (is(C S == super))
            foreach (A; S)
               static if (is(A==BASE))
                  return true;
         return is(C==BASE);
      }();
   }

artur

I like that! Avoids importing std.traits, And will correctly handle interfaces as well.

Reply via email to