Aquivalent References as in C++?
Namespace
rswhite4 at googlemail.com
Tue Apr 17 01:02:01 PDT 2012
Now i have something like this. It works and manipulates lvalues
so that i can pass my objects by ref to except null.
But is this smart?
class Bar {
public:
int x;
static ref Bar opCall(int x) {
static Bar b;
b = new Bar(x);
return b;
}
this(int x) {
this.x = x;
}
}
class Foo {
private:
Bar _bar;
public:
int y;
this() { }
this(ref Bar b) {
//assert(b !is null);
writefln("B.x %d", b.x);
}
}
Bar b = new Bar(42);
new Foo(b); // works
new Foo(null); // compiler error
new Foo(Bar(23)); // works
new Foo(Bar(25)); // works
More information about the Digitalmars-d-learn
mailing list