Create variable for RedBlackTree range

Gerald gerald.b.nunn at gmail.com
Sat Apr 28 17:50:23 UTC 2018


On Saturday, 28 April 2018 at 17:20:46 UTC, Jonathan M Davis 
wrote:
> On Saturday, April 28, 2018 16:36:41 Gerald via 
> Digitalmars-d-learn wrote:
>> [...]
>
> In general, you just use auto, but that's not going to work if 
> you can't directly initialize the variable. In that case, the 
> solution is typeof. e.g. something like
>
> typeof(prompPosition[]) range;
>
>> [...]
>
> If you mean the interfaces from std.range.interfaces, I don't 
> think that anything in Phobos uses them except for that module, 
> and I expect that very little range-based code in general uses 
> them. Ranges are almost always structs. There are rare cases 
> where those interfaces make sense, but ranges in general don't 
> use them. Rather, range-based code is almost always templated.
>
> - Jonathan M Davis

Thanks for the quick reply and the pointer in the right 
direction, I ended up using the ReturnType template to make it 
work:

ReturnType!(promptPosition.lowerBound) range;



More information about the Digitalmars-d-learn mailing list