Error: null dereference in function _Dmain

Namespace rswhite4 at googlemail.com
Mon Jul 2 14:45:58 PDT 2012


At last a further Stack overflow, maybe you could explain me why.

It comes if i try to outsource the redundant code with a mixin 
template like this:

[code]
mixin template TRef(T : Object) {
private:
	NotNull!(T) _nn;

public:
	@property
	NotNull!(T) GetNN() {
		return this._nn;
	}

	alias GetNN this;
}

class Foo {
/*
private:
	NotNull!(Foo) _nnf;
*/
public:
	mixin TRef!(Foo);

	this() {
		this._nnf = NotNull!(Foo)(this);
	}

	void Identicate() const {
		writeln(Foo.stringof);
	}
/*
	@property
	NotNull!(Foo) GetNN() {
		return this._nnf;
	}

	alias GetNN this;
*/
}
[/code]

Without the mixin it compiles fine.
I tried comment out "alias this" in the mixin template and write 
it into the class, but it seems that it isn't relevant.


More information about the Digitalmars-d-learn mailing list