Returning fixed size arrays

Tobias Pankrath via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Jun 25 14:15:37 PDT 2014


On Wednesday, 25 June 2014 at 20:55:47 UTC, bearophile wrote:
> Is it possible and a good idea to change the D ABI to make code 
> like this avoid an array copy in 100% of the cases (without 
> inlining)?
>
>
> ubyte[1000] foo() nothrow @safe {
>     typeof(return) data;
>     // some code here.
>     return data;
> }
> void main() nothrow {
>     immutable data = foo();
> }
>
>
> Bye,
> bearophile

Isn't this a case for Named Return Value Optimization?



More information about the Digitalmars-d-learn mailing list