On Saturday, 12 February 2022 at 00:41:22 UTC, H. S. Teoh wrote:
How about this? -------- final class Boxed(T) { T payload;alias payload this; // caveat: probably not a good idea in generalthis(T val) { payload = val; } } Boxed!int i = new Boxed!int(123); int j = i; // hooray, implicit unboxing! i = 321; // even this works --------
Pretty neat solution, you need an extra type but that's not much. If alias this would be removed in D, would tricks like these suddenly become impossible?