Is this a bug in std.typecons.Tuple.slice?

Saurabh Das via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Feb 4 07:17:54 PST 2016


On Thursday, 4 February 2016 at 12:28:39 UTC, Saurabh Das wrote:
> This code:
> [...]

Update: Simplified, this also doesn't work:

void main()
{
     import std.typecons;
     auto tp = tuple(10, false, "hello");

     auto u0 = tp.slice!(0, tp.length);
     auto u1 = tp.slice!(1, tp.length);
     auto u2 = tp.slice!(2, tp.length);

     static assert(is(typeof(u0) == Tuple!(int, bool, string)));
     static assert(is(typeof(u1) == Tuple!(bool, string)));
     static assert(is(typeof(u2) == Tuple!(string)));

     assert(u2[0] == "hello");
     assert(u0[2] == "hello");
     assert(u1[1] == "hello");    // This fails
}

rdmd erasetype.d
core.exception.AssertError at erasetype.d(16): Assertion failure

Any ideas?


More information about the Digitalmars-d-learn mailing list