Re: variable template question

2018-01-14 Thread ag0aep6g via Digitalmars-d-learn
On Sunday, 14 January 2018 at 16:23:18 UTC, kdevel wrote: Why does this compile while both of the commented lines give a compile error. The code boils down to this: struct decimal32 { this(int x) {} } immutable decimal32 c = 3; /* works */ void main () { immutable decimal32 i = 1

variable template question

2018-01-14 Thread kdevel via Digitalmars-d-learn
vartmpl.d ``` import std.stdio : writeln; import decimal : decimal32; template F(T) { immutable T c = 3; } void foo (T) () { immutable T t = 1; } void main () { // immutable decimal32 i = 1; // Error: none of the overloads of '__ctor' are callable using a immutable object // foo!dec