C++ reference type
BCS
BCS at pathlink.com
Mon Jun 26 09:20:16 PDT 2006
How about some sort of cast to l-value syntax that would be used from
the calling code. It would generate a copy and pass a reference to it.
For that matter, any reason not to do that by default?
Dave wrote:
>
[...]
>
>
> There's one more irritating limitation, and that is the ability to pass
> a temporary byref:
>
> private import std.stdio;
> void main()
> {
> // error: (opCall)(100) is not an lvalue
> writefln(foo(MyStruct(100),100));
> }
> int foo(inout MyStruct s, int i)
> {
> return s.i * i;
> }
> struct MyStruct
> {
> private int i = 0;
> static MyStruct opCall(int i)
> {
> MyStruct s;
> s.i = i;
> return s;
> }
> }
>
More information about the Digitalmars-d
mailing list