On 15.04.2016 19:13, Eric wrote:
   1 alias J = const C;
   2
   3 void main(string[] args)
   4 {
   5     J a = new C();
   6     I!(J) i = a;
   7 }
   8
   9 interface I(V) { }
  10
  11 class F(V) if (is(V : I!(V))) { }
  12
  13 class C : I!(J)
  14 {
  15     F!(J) m;
  16 }

The above code gives the following compile error:
Error:
template instance F!(const(C)) does not match template declaration F(V)
if (is(V : I!V))
on line 15.

If I change line 1 to "alias J = C;" the code will compile.  The problem
seems to be
the template constraint on line 11.  I think the constraint says, "If V
can be automatically
converted to I!(V) then this template can be used".  However, line 6
does not give
an error, and it seems to be automaticaly converting J to I!(J).

Line 6 isn't accepted either. If you remove the constraint, the compiler complains about it. So it's just the next error in line.

And really const C can't be converted to I!(const C) implicitly. The former is const, the latter is mutable => no go.

Reply via email to