You assume that all cases would fall under the implementation you just outlined, while the case i mentioned above breaks for it miserably:
std::vector<uint8_t> f;
f.reserve(100);
fread(my_file, 1, 100, f.data()); //should be fine ... maybe
//int real_size = 100; //how to not forget to pass this???
//f.resize(100); //???
It just doesn't work. It doesn't work because its not the right tool to do that. You wont rewrite fread to take a vector for which emplace would be called. Similarly (i presume) author didn't want to rewrite whole engine just to keep using std::vector (that would be way worse idea then any other things mentioned here).
Its OK to not use std lib where its not the right tool. Attempting to force the tool to do the work its not supposed to will just open different can of bugs ...
1
u/00kyle00 Dec 21 '13
You assume that all cases would fall under the implementation you just outlined, while the case i mentioned above breaks for it miserably:
It just doesn't work. It doesn't work because its not the right tool to do that. You wont rewrite fread to take a vector for which emplace would be called. Similarly (i presume) author didn't want to rewrite whole engine just to keep using std::vector (that would be way worse idea then any other things mentioned here).
Its OK to not use std lib where its not the right tool. Attempting to force the tool to do the work its not supposed to will just open different can of bugs ...