Does anyone care if Tuple.slice() returns by ref?

tsbockman via Digitalmars-d digitalmars-d at puremagic.com
Sun Feb 7 05:01:14 PST 2016


On Sunday, 7 February 2016 at 12:51:07 UTC, Ola Fosheim Grøstad 
wrote:
> On Sunday, 7 February 2016 at 12:28:07 UTC, tsbockman wrote:
>> That is surprising indeed, but I don't see how fixing it would 
>> solve the Tuple.slice() memory alignment issues.
>
> Why won't a reinterpret cast work?
>
> struct tupleX {
>   T0 _0;
>   T1 _1;
> }
>
> struct tupleX_slice_1_2 {
>   T0 _dummy0;
>   T1 _0
> }

That is essentially what my PR does. But, some people are unhappy 
with the thought of a slice's type not matching the type of the 
equivalent standard Tuple:

Tuple!(int, bool, string) foo;
const bar = foo.slice!(1, 3)();

static assert(! is(typeof(bar) == Tuple!(bool, string)));


More information about the Digitalmars-d mailing list