What is the cost of sizeof?
I would expect:
sizeof
evaluates the size of the type at compile time (evaluating only the type of the expression), so it has no runtime cost (it's exactly as if you put there a constant).
Since a dynamic array is referred to by a pointer, sizeof
will tell you the size of the pointer. In general you must keep track manually of the "real" size of dynamic arrays, there's no supported way to know it from the allocator.