Is this documented behaviour?
monarch_dodra
monarchdodra at gmail.com
Wed Jul 24 07:52:51 PDT 2013
On Tuesday, 23 July 2013 at 20:13:33 UTC, John Colvin wrote:
> On Tuesday, 23 July 2013 at 17:06:37 UTC, Dicebot wrote:
>> On Tuesday, 23 July 2013 at 17:03:52 UTC, John Colvin wrote:
>>> Sorry, I should have been more clear. It's the first case
>>> that seems weird to me.
>>
>> Why? '*aptr' is 'a' pretty much by definition of pointer
>> dereferencing.
>
> To be honest, I wasn't expecting foo(*aptr) to compile at all,
> with a "taking address of temporary" error or similar.
>
> It's clearly the right behaviour to allow it, but it took me by
> surprise at first.
"Pass-by-Ref" is pretty much sugar for "pass-pointer-by-value".
Basically, if you can take the address of the argument, then
passing it is fair game. It's because you can't take the address
of a temporary that you can't pass a temporary by ref (unless you
are Microsoft Visual Studio, then there's no problem at all
apparently 0_o).
Of course, "*aptr" does not return a temporary, so passing that
is fair game too.
More information about the Digitalmars-d-learn
mailing list