On Saturday, 8 February 2020 at 08:22:46 UTC, Adnan wrote:
Just a foreword, this is for learning purposes, hence I am not
using the dynamic array or Array!T.
I have a structure that maintains a heap allocated sized array
inside.
struct LifoStack(T) {
T[?] data;
}
T[N] is a static array and N must be a compile time constant such
as a literal, an enum, or a template parameter. So you cannot
change its size. This is the distinct difference between static
and dynamic arrays.
Also, how can I create runtime-determined sized fixed array in
the heap?
The heap is for dynamic allocations, I don't understand why to
store a fixed-length array in the heap. Why not just to make data
dynamic array?