Actions
Bug #758
openOFVector needs to separate allocation and element construction
Start date:
2017-06-09
Due date:
% Done:
0%
Estimated time:
Module:
Operating System:
Compiler:
Description
The current OFVector implementation does not separate element construction from memory allocation, i.e.
capacity() == 10means at least 10 elements have been constructed even if
size() == 0. This is not only agains the C++ standard but also has serious ramifications:
1. The element type used within an OFVector needs to be default constructible, which is an unnecessary constraint that leads to inefficient code.
2. Recursive structures based on OFVector cause a stack overflow!! See this example:
struct Recursive : OFVector<Recursive>
{
// data members
};
Recursive r; // stack overflow, since the default constructor constructs elements, which themselves recursively construct more elements.
Actions