Andrei Alexandrescu escribió:
Lionello Lunesu wrote:

"Jeremie Pelletier" <[email protected]> wrote in message news:[email protected]...
It's especially bad since if you modify the function prototype and change ref, you have all your calls to update too.

That must be the best argument to introduce repeating ref and out!

L.

// untested
struct Ref(T)
{
    private T* _data;
    this(ref T data) { _data = &data; }
    ref T get() { assert(_data); return *_data; }
    alias get this;
}
Ref!(T) byRef(ref T data)
{
    return Ref!(T)(data);
}

...

void fun(Ref!int rint) { ... }
...
int x;
fun(byRef(x));


Andrei

Have you heard about standardization? ;-)

But yeah, there's the problem with functions in templated code... I don't know what to do with that...

Reply via email to