[swift-evolution] Does protocol support add to an object's size?
razielim at gmail.com
Thu Feb 16 21:53:58 CST 2017
> On 15 Feb 2017, at 18:51, Daryle Walker via swift-evolution <swift-evolution at swift.org> wrote:
> I don't know how protocol support works. I asking because I want to maintain the stride of an array being the total count times the stride of the element, which would complicate nominal arrays if adding protocols to one breaks that.
> Sent from my iPhone
> swift-evolution mailing list
> swift-evolution at swift.org
The stride of an Array<T> is the width of a pointer, since Arrays are stored indirectly. Also, the allocated capacity may be greater than the number of elements actually contained in the Array. If you want a fixed-size group of elements, with a stride equal to the number of elements multiplied by the per-element stride, use a tuple.
More information about the swift-evolution