Wrapping a C-style Array (Pointer + Length) in a Range Interface

via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Jul 7 05:26:31 PDT 2015


I'm currently developing a high-level wrapper for FFMPEG at

https://github.com/nordlow/justd/blob/master/tests/t_ffmpeg.d

My question now becomes how to most easily wrap the iteration 
over streams at

https://github.com/nordlow/justd/blob/master/tests/t_ffmpeg.d#L150

https://github.com/nordlow/justd/blob/master/tests/t_ffmpeg.d#L152

in a nice D-style range interface.

Do I have to allocate a new D array and copy the `AVStream*` 
elements into that or is there a convenience wrapper for 
constructing a lazy range from a C style Array-pointer plus 
array-length?

Note that the elements of the C array are pointers to structs, in 
this case instances of `AVStream`. This, of course, complicates 
the matter with regard to GC-safety.

Comments on that please :)


More information about the Digitalmars-d-learn mailing list