range-v3 icon indicating copy to clipboard operation
range-v3 copied to clipboard

Question about spliting a range into subranges by iterator or offset

Open ashley-b opened this issue 2 years ago • 1 comments

My question is about split, is there a way to split a range into subranges via iterators or offsets

I uses gsl::span and this helper function currently, but would like to switch to range library for this.

    template< typename T >
    std::pair< gsl::span< T >, gsl::span< T > > bisect(gsl::span< T > s, typename gsl::span< T >::index_type position)
    {
        return { s.first(position), s.subspan(position) };
    }

I see split is close to what am after, but it only works by delimiter value or predicate far as I can see.

Thanks for the great library.

ashley-b avatar Apr 02 '22 11:04 ashley-b

IIRC, the recommendation is to ask this kind of questions on SO. Maybe https://github.com/ericniebler/range-v3/discussions is also OK.

JohelEGP avatar Apr 02 '22 14:04 JohelEGP