[info] type_name = "std::list" stub_template_params = [1] ctype = "LIST_TYPE" header = "list" # Old: typeName = "std::list<" ns = ["namespace std"] numTemplateParams = 1 replaceTemplateParamIndex = [] 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.size()); // 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.size()); 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::List::type>" func = """ #ifdef __GLIBCXX__ static constexpr size_t element_size = sizeof(std::_List_node); #else static_assert(false && "No known element_size for list. See types/cxx11_list_type.toml"); #endif static constexpr auto childField = make_field("[]"); auto list = std::get(d.val); el.container_stats.emplace(result::Element::ContainerStats{ .capacity = list.length, .length = list.length, }); el.exclusive_size += el.container_stats->length * (element_size - sizeof(T0)); stack_ins(inst::Repeat{ list.length, childField }); """