June 16, 2011
Hi,

I am trying to instantiate a Tuple that contains an immutable field. Is there a way to do this with the current implementation? The compiler gives me this error:

std/typecons.d(383): Error: can only initialize const member
_field_field_0 inside constructor
tuple_test.d(5): Error: template instance
std.typecons.Tuple!(immutable(int)).Tuple.__ctor!(int) error
instantiating
tuple_test.d(3): Error: function D main has no return statement, but
is expected to return a value of type int

here is the code:

import std.typecons;

int main()
{
  Tuple!(immutable(int)) var = Tuple!(immutable(int))(5);
  assert(var[0] == 5);
}

Thanks!
June 17, 2011
Jose Armando Garcia:

> I am trying to instantiate a Tuple that contains an immutable field. Is there a way to do this with the current implementation?

I think this is not yet possible. I am not sure, but maybe even small changes to conts are needed to fix this problem.

Bye,
bearophile