Thanks a lot. I read it in the D Cookbook from Adam D. Ruppe. In the chapter of memory management there is a topic, how to build reference counted objects. Here this construct is explained.
Kind regards André On Monday, 23 March 2015 at 20:58:48 UTC, Namespace wrote:
Something like that? struct PrimitiveRef(T) { private T* _value; @property ref inout(T) get() inout pure nothrow { assert(_value); return *_value; } alias get this; this(T val) { _value = new T(val); } } alias BoolRef = PrimitiveRef!bool; void test(BoolRef b) { b = true; } void main() { BoolRef b = false; test(b); assert(b == true); }