On Saturday, 22 November 2014 at 15:00:00 UTC, Eric wrote:
Yes, but if I don't declare the class T as immutable, I don't think this constraint will work.
You're mistaken. It works just fine. class X /* not immutable */ { private int x; this(int x) pure { this.x = x; } } template foo(T : immutable Object) { void foo(T thing) {} } void main() { foo(new immutable X(5)); }