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".

Reply via email to