2 #include "structurebuilder.h"
9 StructureBuilder::StructureBuilder(vector<char> &s, unsigned max_parts):
13 parts.reserve(max_parts);
16 void *&StructureBuilder::add(std::size_t size, std::size_t align)
18 if(parts.size()>=parts.capacity())
19 throw invalid_operation("StructureBuilder::add");
22 Part &part = parts.back();
23 part.offset = storage.size()+align-1;
24 part.offset -= part.offset%align;
26 storage.resize(part.offset+size);
28 p.pointer = storage.data()+p.offset;
30 return parts.back().pointer;