Function, signatures and tuples

Pelle Månsson pelle.mansson at gmail.com
Tue Nov 16 13:03:26 PST 2010


On 11/13/2010 11:43 AM, Russel Winder wrote:
> On Sat, 2010-11-13 at 08:18 +0000, Iain Buclaw wrote:
> [ . . . ]
>> import std.typecons; ?
>
> Hummm... I thought I had put that in but clearly I had not :-((  OK so
> that explains the bulk of the problems on this code, I knew it was
> something stupid on my part, thanks for spotting it.
>
> However, now we may be getting to something more serious.  The line:
>
>           foreach ( i ; 0 .. numberOfTasks ) { inputData[i] = tuple ( 1 + i * sliceSize , ( i + 1 ) * sliceSize , delta ) ; }
>
> now results in the error:
>
>          /home/users/russel/lib.Linux.x86_64/DMD2/bin/../../src/phobos/std/typecons.d(662): Error: can only initialize const member _field_field_2 inside constructor
>          /home/users/russel/lib.Linux.x86_64/DMD2/bin/../../src/phobos/std/typecons.d(26): Error: template instance std.typecons.tuple!(long,long,immutable(double)) error instantiating
>
> Which at first sight seems to indicate an error in the typecons package
> of Phobos.  On the other hand, it is probably more reasonable to assume
> I still have something stupid wrong in my code.

It's not your code, you can work around it with cast(double)delta, or 
using tuple!(long,long,double) explicitly, I think.

Tuple doesn't handle immutable or const really well, yet.


More information about the Digitalmars-d mailing list