On Thursday, 22 November 2012 at 16:09:46 UTC, Joshua Niehus wrote:
On Thursday, 22 November 2012 at 15:47:11 UTC, Frederik Vagner wrote:
I am trying to make a templated class to accept any numeric type:

class example(Type) if (isNumeric(Type))
{
   Type k = to!Type(1);
   ....
}

however I always get a compiler erro stating I cannot make that conversion. How do I fix it?

// phobos
import std.stdio, std.conv, std.traits;
class Example(T) if (isNumeric!T)
{
    T k = to!T(1);
}

void main()
{
    auto x = new Example!double();
    writeln(x.k);
}

Now do it for complex number please ^^

Reply via email to