Just for you, a slightly adapted version: ---- import std.stdio; struct A { public int id = 0; this(int id) { this.id = id; } ref A byRef() { return this; } } void foo(ref const A a) { writeln(a.id); } void main() { foo(A(42).byRef()); } ----