Setting a hard limit on slice size, is this possible?

james.p.leblanc james.p.leblanc at gmail.com
Fri Aug 6 10:50:19 UTC 2021


I am aware of the "capacity" concept with slices.

But, I would like to know if it is possible to set a
hard limit on a slice size.

I prefer it to error and crash instead of a doing an
extension or reallocation.

I understand my question screams of "convoluted
thinking".  But, I need to align my slice according to
certain criteria.

(Alternatively, I could use an array ... if I could
align that according to criteria known at compile
time.  Is this possible?).

I have a working solution (ugly trick, maybe is a
better description) to align my slice as desired.

But, the solution would be more robust if I could
guarantee that the slice is never moved in memory.

Any thoughts, hints, etc are welcome!

James





More information about the Digitalmars-d-learn mailing list