Say I wanted to initialise a std::vector
of objects e.g.
class Person { int ID; string name; ...}
from a file that contains a line for each object. One route, is to override operator>>
and simply std::cin>>temp_person
, another - which I used to favour is to use sscanf("%...", &...)
a bunch of temporary primitive types and simply .emplace_back(Person(temp_primitives...)
.
Which way achieves the quickest runtime ignoring memory footprint? Is there any point in mmap()
ing the entire file?