On Monday, 21 December 2015 at 09:44:20 UTC, Shriramana Sharma wrote:
Hello. I want to define a template specialization using traits:

import std.stdio, std.traits;
void func(T)(T t) { writeln(1); }
void func(T)(T t) if(isIntegral!T) { writeln(2); }
void main()
{
    func(1);
}

But I'm getting an error saying that the called function matches both. If it were a single type, I know I have to put the specialization as in:

void func(T: int)(T t) { writeln(2); }

and that works, but how to make it more generic than that?

void func(T)(T t) if(!isIntegral!T) { writeln(1); }
void func(T)(T t) if(isIntegral!T) { writeln(2); }

:)

Reply via email to