Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <sstream>
- #include <string>
- #include <vector>
- #include <utility>
- using namespace std;
- vector<string> ReadStrings(istream& stream, bool use_move)
- {
- vector<string> strings;
- string s;
- while (stream >> s)
- {
- if (use_move)
- {
- //cout << "s = " << s << "\n";
- strings.push_back(move(s));
- //cout << "s = " << s << ", strings.back() = " << strings.back() << "\n";
- }
- else
- {
- strings.push_back(s);
- }
- }
- return strings;
- }
- string GenerateText()
- {
- const int SIZE = 1'000'000'000;
- const int WORLD_LENGTH = 10'000'000;
- string text(SIZE,'a');
- for (int i = WORLD_LENGTH; i < SIZE; i += WORLD_LENGTH)
- {
- text[i] = ' ';
- }
- return text;
- }
- int main()
- {
- /*for (const string& s : ReadStrings(cin))
- {
- cout << s << "\n";
- }*/
- const string text = GenerateText();
- {
- //LOG_DURATION("without move");
- istringstream stream(text);
- ReadStrings(stream, false);
- }
- {
- //LOG_DURATION("with move");
- istringstream stream(text);
- ReadStrings(stream, true);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement