Can you simplify nested Indexed types?

Ali Çehreli acehreli at yahoo.com
Tue Dec 27 16:43:49 UTC 2022


On 12/27/22 07:09, Sergei Nosov wrote:

 > Basically, my idea is to apply `indexed` to an array several times and
 > have all the intermediaries saved in the same variable.

There may be other ways of achieving the same goal without assigning to 
the same variable.

 > I wonder, if there's a way to "collapse" or "simplify" the
 > `Indexed!(Indexed!(int[], Result), Result)` type to just
 > `Indexed!(int[], Result)` ?

If what you are looking for is a way of defining a variable for "any 
InputRange that produces a specific type (size_t in this case)", then 
there is inputRangeObject, which uses OOP:

   https://dlang.org/phobos/std_range_interfaces.html#InputRange

I have an additional example here:

 
http://ddili.org/ders/d.en/ranges_more.html#ix_ranges_more.inputRangeObject

Ali



More information about the Digitalmars-d-learn mailing list