Max:
transferAttributes attaches the attributes to the local declaration. I'd be surprised if they were copied to the outer declaration. Or did you mean attributing the return *type*?

The declaration. The type, I guess I'd use an alias. Though, I guess the alias syntax limitations would probably forbid that.

So yes, the local declaration is attributed, that works. How do I propagate the attribute to the returned value?


Also, dropping the auto return is not accepted by the compiler, even though it seems natural for me:

@(__traits(getAttributes, origin)) To transferAttributes(alias origin, To)(To t)
{
    @(__traits(getAttributes, origin)) To temp = t;
...

'origin' is a template parameter and should be reachable to determine the return type.

That's a bug.

Already filed?

 
Anyway, you are attributing the function declaration here, not the return type

Hmm. Would @(attr) { ReturnType } functionName (...)  work?


 
, which is another problem as it looks we do not have a syntax for that and "auto" is required:

auto foo()
{
    @attr struct S {}
    return S.init;
}