Is this a bug in std.typecons.Tuple.slice?
Marco Leise via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Feb 5 22:34:05 PST 2016
Am Sat, 06 Feb 2016 04:28:17 +0000
schrieb tsbockman <thomas.bockman at gmail.com>:
> On Friday, 5 February 2016 at 19:16:11 UTC, Marco Leise wrote:
> >> > 1. Removing 'ref' from the return type
> >
> > Must happen. 'ref' only worked because of the reinterpreting
> > cast which doesn't work in general. This will change the
> > semantics. Now the caller of 'slice' will deal with a whole new
> > copy of everything in the returned slice instead of a narrower
> > view into the original data. But that's a needed change to fix
> > the bug.
>
> Actually, it's not:
> https://github.com/D-Programming-Language/phobos/pull/3973
>
> All that is required is to include a little padding at the
> beginning of the slice struct to make the alignments match.
I don't want to sound dismissive, but when that thought came
to my mind I considered it unacceptable that the type of
Tuple!(int, bool, string).slice(1, 3) would be something
different than Tuple!(bool, string). In your case
Tuple!(TuplePad!4LU, bool, string). That's just a matter of
least surprise when comparing the types.
I'll let others decide, since I never used tuple slices.
--
Marco
More information about the Digitalmars-d-learn
mailing list