@JLBorges - Thanks for that, I didn't really know much about the uses of std::istream_iterator. Would you please be so kind as to clarify two things for me?
- return { std::istream_iterator<int>(file), std::istream_iterator<int>() } ; I believe you're constructing a vector here using initializer_list? The reference stated that a default constructed std::istream_iterator holds an end-of-stream state, so at first it would seem like you are saying something like stream.begin() until stream.end(). However, I didn't think initializer_list worked that way for vectors. Could you please clarify?
- myVector.push_back(temp); // from L B's code would using myVector.push_back(std::move(temp)); be another worthwhile optimization here?
note, if you want efficiency as in speed (rather than just easy-to-maintain code), there are other ways to read numbers from a file to look at (but only after profiling and determining that this is a bottleneck!): http://www.cplusplus.com/forum/beginner/88679/#msg476690