#Storing polymorphic parameter in polymorphic struct upon creation

1 messages · Page 1 of 1 (latest)

pine crater
#

Is there a way to store elementCount into capacity? This seems like a good time to use parapoly but a RingBuffer should really know its own capacity and it feels silly passing the elementCount in upon creation and then calling something like ring_buffer_init() to grab len(ringBuffer.buffer) to store in ringBuffer.capacity

RingBuffer :: struct($elementType: typeid, $elementCount: int) {
    buffer : [elementCount]elementType,
    capacity : int,
    writer : int,
    reader : int,
}
glass stone
#

why even have the capacity?