How to convert member function to free function?

Andrey Zherikov andrey.zherikov at gmail.com
Fri Sep 18 19:10:04 UTC 2020


On Friday, 18 September 2020 at 18:43:38 UTC, H. S. Teoh wrote:
> Why can't you return by ref, which would also avoid the copying?
>
> 	ref S foo(return ref S s) { return s; }

Compiler errors out:
onlineapp.d(9): Error: function onlineapp.foo(return ref S s) is 
not callable using argument types (S)
onlineapp.d(9):        cannot pass rvalue argument S() of type S 
to parameter return ref S s




More information about the Digitalmars-d-learn mailing list