[info] type_name = "std::vector" stub_template_params = [1] ctype = "SEQ_TYPE" header = "vector" # Old: 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); } } """ handler = """ template struct TypeHandler> { using type = types::st::Pair< DB, types::st::VarInt, types::st::Pair< DB, types::st::VarInt, types::st::List::type>>>; static types::st::Unit getSizeType( const %1% & container, typename TypeHandler>::type returnArg) { 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([&it](auto ret) { return OIInternal::getSizeType(it, ret); }); } return tail.finish(); } }; """