DMD producing huge binaries

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Thu May 19 15:17:37 PDT 2016


On 5/19/2016 8:39 AM, Steven Schveighoffer wrote:
>> template(T) foo if (someConstraints)
>> {
>>     struct Result
>>     {
>>        T t;
>>     }
>>
>>     auto foo(T t)
>>     {
>>        return Result(t);
>>     }
>> }
>
> This solution works awesomely, actually. It even produces smaller code than
> moving the struct completely outside.
>
> I'm going to use this mechanism in iopipe to get my voldemorts back :)


Consider using a 'static struct'. A non-static struct will include a hidden 
member that points to the stack frame of foo(), i.e. "produces smaller code".


More information about the Digitalmars-d mailing list