Presently, I set the value of a std::vector
from an std::ostringstream
as follows:
void
foo(std::vector &am
if there is a more efficient way
You may want to call reserve
on your data
and use the range insert
member directly on data
instead of using a copy-assignment. The thing about vector
s that you need to remember is that every node may potentially increase the size (and relocate all elements). So, you're better off allocating the memory in one go (if you know how many objects you will be storing -- which you do know here) and leverage this fact.