Converting a number to complex

Artur Skawina art.08.09 at gmail.com
Fri Nov 23 10:37:33 PST 2012


On 11/23/12 18:06, Joshua Niehus wrote:
> meh, couldn't resist:
> 
> import std.stdio, std.conv, std.traits, std.complex;
> template isComplex(T)
> {
>     static if (is(T == Complex!double))
>     {
>         enum bool isComplex = true;
>     }
>     else static if (is(T == Complex!float))
>     {
>         enum bool isComplex = true;
>     }
>     else static if (is(T == Complex!real))
>     {
>         enum bool isComplex = true;
>     }
>     else {
>         enum bool isComplex = false;
>     }
> }

   template isComplex(T) {
      static if (is(T _ == Complex!CT, CT))
         enum isComplex = true;
      else
         enum isComplex = false;
   }

artur


More information about the Digitalmars-d-learn mailing list