Trait hasIndexing

Jonathan M Davis via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Oct 11 07:20:29 PDT 2016


On Tuesday, October 11, 2016 10:08:02 Nordlöw via Digitalmars-d-learn wrote:
> I can't find any traits `hasIndexing!R` corresponding to
> `std.range.primitives.hasSlicing!R`
>
> that is `true` iff `R` has `opIndex[size_t]` defined. Is there
> one?
>
> If not what should I use instead?

The traits in std.range are specifically for ranges, and isRandomAccessRange
already covers indexing, which is why there isn't a separate trait for
indexing in there. There certainly _could_ be one in std.traits, but there
isn't at present.

- Jonathan M Davis



More information about the Digitalmars-d-learn mailing list