See the following code:
import std.stdio;
void foo(ref int x)
{
writefln("%s", x);
}
void main(string[] args)
{
int y = 0;
foo(y++);
}
When compiled it produces this error:
test.d(11): Error: function test.foo (ref int x) is not callable
using argument types (int)
On Sunday, 27 December 2015 at 16:05:39 UTC, Gary Willoughby
wrote:
If I remove the post-increment of the y variable if works. Is
this an rvalue reference issue? Would you expect this to work?
This should work with *pre*-increment, but not post-increment.
Post-increment works like this:
int
On Sunday, 27 December 2015 at 16:05:39 UTC, Gary Willoughby
wrote:
void foo(ref int x)
foo(y++);
If I remove the post-increment of the y variable if works. Is
this an rvalue reference issue?
Yes, but more than that, what, exactly, would you expect from
that? The order of operations
On Sunday, 27 December 2015 at 18:54:25 UTC, Adam D. Ruppe wrote:
On Sunday, 27 December 2015 at 16:05:39 UTC, Gary Willoughby
wrote:
[...]
Yes, but more than that, what, exactly, would you expect from
that? The order of operations with the postfix ++ operator and
ref would probably lead to