variable template question

kdevel kdevel at vogtner.de
Sun Jan 14 16:23:18 UTC 2018


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!decimal32; //  Error: none of the overloads of '__ctor' 
are callable us
ing a immutable object, candidates are:
    alias c = F!decimal32.c;
    c.writeln;
    writeln (typeof (c).stringof);
}
```

$ dmd -g vartmpl.d decimal.git/libdecimal.a
$ ./vartmpl

3
immutable(Decimal!32)

Why does this compile while both of the commented lines give a 
compile error. decimal ist http://rumbu13.github.io/decimal/


More information about the Digitalmars-d-learn mailing list