lvalue forwarding struct?
Chad J
gamerChad at _spamIsBad_gmail.com
Tue Aug 21 10:46:54 PDT 2007
What I am looking for is a templated struct that simply wraps a
variable, and ensures lvalueness is preserved for that variable.
Ex:
foo(bar) *= 9;
In this case foo is to be a function that acts on bar, and then makes
sure that bar has the *= 9; applied to it.
It might look like this:
int foo(inout int input)
{
input++;
return lvalue(input);
/* lvalue(...) is an opCall constructor for the lvalue templated
forwarding struct. */
}
Thus we could write
int bar = 3;
foo(bar) *= 9;
printf( "%d", bar ); // prints 36
One possible use case would be as a hack to get around certain
shortcomings of properties for the time being.
So does anyone have such a thing that they want to share?
Otherwise this is something I might do.
More information about the Digitalmars-d-learn
mailing list