On 7 July 2013 00:49, Timon Gehr <timon.g...@gmx.ch> wrote: > 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. >
Perhaps what you say is true, but does that mean something to the effect of what I'm trying to demonstrate is impossible? I feel like it would be a much cleaner solution than any of the others presented in this thread...