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