Setting a hard limit on slice size, is this possible?
james.p.leblanc
james.p.leblanc at gmail.com
Fri Aug 6 16:32:59 UTC 2021
On Friday, 6 August 2021 at 11:58:59 UTC, Paul Backus wrote:
> struct MySlice(T, size_t maxLength)
> {
> private T[] payload;
> invariant(payload.length <= maxLength);
> this(T[] slice) { payload = slice; }
> T opIndex(size_t i) { return payload[i]; }
> // etc.
> }
```
Paul,
Thanks very much for your reply. I understand only
a fraction of the suggested solution. I will need to
digest this a bit, and do some more background reading
on templates.
My initial, naive attempts to use this in a simple main()
were unsuccessful. I'll keep plugging at it ...
Best Regards,
James
More information about the Digitalmars-d-learn
mailing list