I have a defined class A
and an std::vector
vec
that stores a series of A
instances. I attempt to write a function that appends an arbitrary number of A
instances to vec
.
Should I use vec.reserve()
along with vec.push_back()
since constantly resizing vector is expensive? Or, should I use vec.insert()
?
Currently, I'm not sure if I should design the function to accept a variable number of arguments using variadic functions or a vector of A
instances that I'd like to combine and then concatenate with vec
?
What is an efficient way to design this function (speed is critical and A is a complex class)?
Aucun commentaire:
Enregistrer un commentaire