GArray can be useful in many situations. But its functionality is not as
developed as other containers. This patch adds the fill, first/last
and index_range.
Details
- Reviewers
Hans Goudey (HooglyBoogly)
Diff Detail
Event Timeline
I think the best solution would be to add a method to both types to set the new memory and size, and then make the function for swap ownership of the memorys
After sorting through different implementation options and looking for the most general method without code generation, I decided to think about something like this. https://developer.blender.org/P3132
Do you have a use case for the first and last functions? Generally I wouldn't expect much complex processing with this type, generic spans or typed spans should usually be used instead.
| source/blender/blenlib/BLI_generic_array.hh | ||
|---|---|---|
| 269–271 | This doesn't work when the type is nontrivial. The CPPType methods should be used instead. | |
Indeed, this patch was proposed before I knew that features are only added when really needed.
I found a workaround for the need to swap memory between the template and generic containers. And since that was also taken out of this patch, I feel like it's redundant now.
I'd say it would be handy to represent it as a range, but I don't have any examples.