On 07/06/2013 03:34 AM, Manu wrote:
Okay, so I feel like this should be possible, but I can't make it work...
I want to use template deduction to deduce the argument type, but I want
the function arg to be Unqual!T of the deduced type, rather than the
verbatim type of the argument given.

I've tried: void f(T : Unqual!U, U)(T a) {}
and: void f(T)(Unqual!T a) {}

Ie, if called with:
   const int x;
   f(x);
Then f() should be generated void f(int) rather than void f(const int).

I don't want a million permutations of the template function for each
combination of const/immutabe/shared/etc, which especially blows out
when the function has 2 or more args.

Note: T may only be a primitive type. Obviously const(int*) can never be
passed to int*.

void f(T)(const(T) a) {}

This will strip off const, immutable and inout, but not shared.

I'd have thought that

void f(T)(const(shared(T)) a) {}

would strip shared as well, but DMD does not match int to const(shared(int)) at all which I think is incorrect.

Reply via email to