<div dir="ltr">On 6 July 2013 11:42, finalpatch <span dir="ltr"><<a href="mailto:fengli@gmail.com" target="_blank">fengli@gmail.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On Saturday, 6 July 2013 at 01:35:09 UTC, Manu wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Okay, so I feel like this should be possible, but I can't make it work...<br>
I want to use template deduction to deduce the argument type, but I want<br>
the function arg to be Unqual!T of the deduced type, rather than the<br>
verbatim type of the argument given.<br>
<br>
I've tried: void f(T : Unqual!U, U)(T a) {}<br>
and: void f(T)(Unqual!T a) {}<br>
<br>
Ie, if called with:<br>
const int x;<br>
f(x);<br>
Then f() should be generated void f(int) rather than void f(const int).<br>
<br>
I don't want a million permutations of the template function for each<br>
combination of const/immutabe/shared/etc, which especially blows out when<br>
the function has 2 or more args.<br>
<br>
Note: T may only be a primitive type. Obviously const(int*) can never be<br>
passed to int*.<br>
</blockquote>
<br></div>
this?<br>
<br>
template f(T)<br>
{<br>
void f (T x)<br>
{<br>
f_i(x);<br>
}<br>
void f_i(Unqual!T x)<br>
{<br>
writefln("%s", x);<br>
}<br>
}<br>
</blockquote></div><br></div><div class="gmail_extra" style>And again, f(T), the signature is wrong. There is also an additional call... twice as slow when non-optimised :/</div></div>