On 07/06/2013 04:06 PM, Manu wrote:
...
It seems that your code works if you put the Template Type explicit:
----
import std.stdio;
import std.traits : Unqual;
void foo(T)(Unqual!T a) {
writeln(typeof(a).stringof, " <-> ", T.stringof);
}
void main() {
int a;
const int b;
immutable int c;
//foo(c); /// Error
foo!(typeof(a))(a);
foo!(typeof(b))(b);
foo!(typeof(c))(c);
}
----
Indeed, hence my point that the type deduction is the key issue here.
It should be possible... maybe a bit tricky though.
The key issue is that the syntax void foo(T)(Unqual!T a); denotes
roughly the opposite of what you think it denotes. Basically, inference
is instructed to find a T, such that Unqual!T is the argument type.