, Branch es? std::vector, .
My suggestion was to actually build a vector filled with (empty) Branches, but at the same time reserve space for its Leafs, for example:
if you write a memory reservation constructor for the Branch / struct class:
struct Branch{
std::vector <Leaf> leaves;
Branch (int expectedL = 10){
leaves.reserve(expectedL);
}
};
then you can do:
std::vector<Branch> branches(10);
or
std::vector<Branch> branches(10, 42);
Not quite what you ask for, but maybe it helps.
source
share