Fun with templates

Vladimir Panteleev vladimir at thecybershadow.net
Fri Jul 5 18:43:40 PDT 2013


On Saturday, 6 July 2013 at 01:35:09 UTC, Manu wrote:
> Okay, so I feel like this should be possible, but I can't make 
> it work...

I don't think D's IFTI allows different argument and parameter 
types...

I think this is possible with a proxy function (a function that 
accepts arguments with any qualifiers, but forwards them to the 
real function after stripping away top-level qualifiers). Should 
be possible to create something that auto-generates such a proxy 
function. A small proxy function will likely be inlined, and 
would avoid template bloat.

Another possible way:

Unqual!T unqual(T)(T v) { return v; }

Then use unqual(x) whenever calling the function (although you'd 
have to remember to, which sucks).


More information about the Digitalmars-d mailing list