How to return a reference to structs?

Andrey Zherikov andrey.zherikov at gmail.com
Sat Nov 6 15:57:23 UTC 2021


On Saturday, 6 November 2021 at 13:57:47 UTC, Ali Çehreli wrote:
> Have you considered std.range.indexed, which should at least 
> cover the case of accessing:
>
>   https://dlang.org/phobos/std_range.html#indexed

I don't need to iterate over whole collection, but subset of it.

> Can you give a little more context for others to come up with a 
> better answer?

I have a [CLI-parsing 
library](https://github.com/andrey-zherikov/argparse) that 
creates a set of argument objects based on UDAs. They are [stored 
in 
array](https://github.com/andrey-zherikov/argparse/blob/master/source/argparse.d#L436) right now. I want to introduce some grouping having something like `struct Group { size_t[] args; }` but face the problem of addressing the objects. As of now I need to be able to iterate over the arguments within a group as well as those that satisfy some condition.


More information about the Digitalmars-d-learn mailing list