Local functions infer attributes?

Daniel N via Digitalmars-d digitalmars-d at puremagic.com
Fri Oct 10 22:09:08 PDT 2014


On Monday, 29 September 2014 at 00:51:26 UTC, Walter Bright wrote:
> On 9/28/2014 5:38 PM, Manu via Digitalmars-d wrote:
>> That said, my friend encountered one of my frequently 
>> recurring pain
>> cases himself yesterday:
>> struct S(T...)
>> {
>>   void f(T args) {}
>> }
>>
>> S!(int, ref S) fail; // <-- no clean way to do this. I need 
>> this very
>> frequently, and he reached for it too, so I can't be that 
>> weird.
>
>   S!(int, S*)

Yet another solution...

http://dpaste.dzfl.pl/e28c55416ce2

... locally you always use ref, but when instantiating another 
template you need to forward the original pointer type to the 
next level... this way it's possible to avoid an explosion of 
"static if":s.


More information about the Digitalmars-d mailing list