There is "isFloatingPointType!T" to find out whether type T is one of the floating point types but I could not find anything equivalent for complex numbers (cdouble, cfloat, creal) in Phobos 2.066 (which I installed with MacPorts for the record). Am I missing something?

My goal was to detect types suitable as scalars in a linear algebra context. I had to do it by hand:

enum bool supportedScalar(T) = is(ScalarTypeOf!T) && !isAggregateType!T;

private {
  alias ScalarTypeList = TypeTuple!(float, double, real,
                                    cfloat, cdouble, creal);
  template ScalarTypeOf(T) {
      static if (is(AliasThisTypeOf!T AT) && !is(AT[] == AT))
          alias X = ScalarTypeOf!AT;
      else
          alias X = OriginalType!T;

      static if (staticIndexOf!(Unqual!X, ScalarTypeList) >= 0)
          alias ScalarTypeOf = X;
      else
static assert(0, T.stringof~" is not a floating point type");
  }
}


Reply via email to