[info] type_name = "std::vector" stub_template_params = [1] header = "vector" # Old: ctype = "SEQ_TYPE" typeName = "std::vector<" ns = ["namespace std"] numTemplateParams = 1 allocatorIndex = 1 [codegen] decl = """ template void getSizeType(const %1% &container, size_t& returnArg); """ func = """ template void getSizeType(const %1% &container, size_t& returnArg) { SAVE_SIZE(sizeof(%1%)); SAVE_DATA((uintptr_t)&container); SAVE_DATA((uintptr_t)container.capacity()); SAVE_DATA((uintptr_t)container.size()); SAVE_SIZE((container.capacity() - container.size()) * sizeof(T)); // The double ampersand is needed otherwise this loop doesn't work with vector for (auto&& it: container) { getSizeType(it, returnArg); } } """ traversal_func = """ auto tail = returnArg.write((uintptr_t)&container) .write(container.capacity()) .write(container.size()); // The double ampersand is needed otherwise this loop doesn't work with // vector for (auto&& it : container) { tail = tail.delegate([&ctx, &it](auto ret) { return OIInternal::getSizeType(ctx, it, ret); }); } return tail.finish(); """ [[codegen.processor]] type = "types::st::VarInt" func = """ el.pointer = std::get(d.val).value; """ [[codegen.processor]] type = "types::st::VarInt" func = """ el.container_stats.emplace(result::Element::ContainerStats{ .capacity = std::get(d.val).value }); """ [[codegen.processor]] type = "types::st::List::type>" func = """ static constexpr auto childField = make_field("[]"); auto list = std::get(d.val); el.container_stats->length = list.length; el.exclusive_size += (el.container_stats->capacity - el.container_stats->length) * sizeof(T0); stack_ins(inst::Repeat{ list.length, childField }); """