The transactions are passed in as a vector. Bitcoin Core's serialization framework understands that all vectors should be serialized with a compact sized unsigned integer preceding each object inthe serialization of the data within the vector in its serialized formitself.