I watched a video by Jonathan Blow Ideas for a new programming language for games , in which he discusses a general scheme in games, which he calls "joint distribution. The idea is that you have a class with several members that are dynamically distributed arrays ( It can be std::vector , but since they are fixed in size, more like the proposed std::dynarray ), you pre-allocate enough memory to store the entire data file and execute only one allocation large enough for All arrays, rather than for each array.
It offers direct language support for this template, which made me wonder if the C ++ standard allows implementations this way? It seems to me that this will require a heroic effort from the compiler to actually implement it as an optimization, but I see no obvious reason why this cannot be done in principle. Does anyone know if this will not be allowed by the standard, or even if there are already implementations that do this optimization in practice?
source share