Why can't rvalues be passed to a 'ref' parameter?

thebluepandabear therealbluepandabear at protonmail.com
Sun Dec 11 04:36:45 UTC 2022


Hello,

I am not really understanding why rvalues cannot be passed to a 
'ref' parameter, the explanation in the book about D I am reading 
was not clear:

"The main reason for this limitation is the fact that a function 
taking a ref
parameter can hold on to that reference for later use, at a time 
when the rvalue
would not be available."

I didn't really understand what Ali meant by this statement, any 
help would be appreciated so this can be clarified.

Regards,
thebluepandabear


More information about the Digitalmars-d-learn mailing list