Tuples with mutable entries?

Hey, I just read through this article by Julius Krumbiegel where he explains the differences of Vectors and Tuples and their memory usage. Mainly the advantage of the compiler knowing that the size of the referenced object does not change.

But, because tuples are immutable objects, their “entry content” can not be changed.
In my current project I have a vector with constant size but changing elements - wouldn’t that also qualify as a stack object? What is the best (hopefully native) type to use in this scenario?
Currently I am using a vector and the allocated memory is going though the roof…

Thanks!

1 Like

Use StaticArrays, and if they really need to be mutable, use the MArray structure.

Yet this is probably something else. There is no fundamental reason for memory allocation be particularly high when using standard arrays either.

edit2: And welcome!

4 Likes