<div dir="ltr">On 6 July 2013 21:23, TommiT <span dir="ltr"><<a href="mailto:tommitissari@hotmail.com" target="_blank">tommitissari@hotmail.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 10:34:04 UTC, Manu wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I'm getting the distinct feeling that what I want is not actually possible.<br>
Which I have to say, is rather surprising.<br>
</blockquote>
<br></div>
This seems like a defect of the language. Perhaps a new language feature is needed. Something like this:<br>
<br>
void foo(inout T)(T t)<br>
{<br>
    t.mutate();<br>
}<br>
<br>
Pass a variable of type S, const(S), or mutable(S), and the function signature becomes:<br>
<br>
void foo(S);<br>
<br>
And then fails if your argument cannot be converted to mutable S.<br>
</blockquote></div><br></div><div class="gmail_extra" style>The way that makes the most sense to me is:</div><div class="gmail_extra" style><br></div><div class="gmail_extra" style>void f(T)(Unqual!T t) {}</div><div class="gmail_extra" style>
<br></div><div class="gmail_extra" style>Given an immutable(T) for instance that I want to call with, it would instantiate the template with the signature void f(T), and then attempt to call it with the immutable(T). If immutable(T) is not convertible to the argument T, then it would produce a compile error as if attempting to call any such function that just receives T.</div>
<div class="gmail_extra" style><br></div><div class="gmail_extra" style>The point here is that I want more control over the signature of the instantiated template (reduce the number of permutations generated for various calls). Template blow-out is perhaps the biggest and most well known day-to-day problem in C++, and tools like this may be very valuable to mitigate the disaster.</div>
</div>