I'd like to get slice that's consist of begining one other slice and end
of yet another slice (all slices belong to the same array of course). Is
it possible? With iterators it's simple, but I can't manage do it with
slices.
http://dpaste.dzfl.pl/443cd4a1
You could make it work like this:
auto slice3 = array[
slice1.length + (slice1.ptr - array.ptr)
..
(slice2.ptr - array.ptr)];
Since the slices all start into array somewhere, subtracting the
pointers gives their start index.
15.11.2013 22:09, Adam D. Ruppe пишет:
You could make it work like this:
auto slice3 = array[
slice1.length + (slice1.ptr - array.ptr)
..
(slice2.ptr - array.ptr)];
Since the slices all start into array somewhere, subtracting the
point
Alexandr Druzhinin:
I'd like to get slice that's consist of begining one other
slice and end of yet another slice (all slices belong to the
same array of course). Is it possible? With iterators it's
simple, but I can't manage do it with slices.
http://dpaste.dzfl.pl/443cd4a1
A simple soluti
15.11.2013 22:13, bearophile пишет:
Alexandr Druzhinin:
A simple solution is to keep two indexes, and use them to find the
slices when you need them.
I did it the first. But then I decided to make it more D-ish and
stumbled upon the issue. Wasn't it wrong decision and would be better to
stay w
On Friday, 15 November 2013 at 15:12:23 UTC, Alexandr Druzhinin
wrote:
15.11.2013 22:09, Adam D. Ruppe пишет:
You could make it work like this:
auto slice3 = array[
slice1.length + (slice1.ptr - array.ptr)
..
(slice2.ptr - array.ptr)];
Si
On Friday, November 15, 2013 22:21:03 Alexandr Druzhinin wrote:
> 15.11.2013 22:13, bearophile пишет:
> > Alexandr Druzhinin:
> >
> > A simple solution is to keep two indexes, and use them to find the
> > slices when you need them.
>
> I did it the first. But then I decided to make it more D-ish
16.11.2013 18:38, Jonathan M Davis пишет:
Well, if you want to get a slice which refers to the same thing as that slice
but includes elements which are in what is being sliced but which aren't in
that slice, you can only get the slice that you want be reslicing whatever the
slices came from. So,
On 11/15/2013 06:55 AM, Alexandr Druzhinin wrote:
I'd like to get slice that's consist of begining one other slice and end
of yet another slice (all slices belong to the same array of course). Is
it possible? With iterators it's simple, but I can't manage do it with
slices.
http://dpaste.dzfl.pl/
On Saturday, November 16, 2013 08:10:30 Ali Çehreli wrote:
> On 11/15/2013 06:55 AM, Alexandr Druzhinin wrote:
> > I'd like to get slice that's consist of begining one other slice and end
> > of yet another slice (all slices belong to the same array of course). Is
> > it possible? With iterators it
10 matches
Mail list logo