Skip to content

Instantly share code, notes, and snippets.

@odeblic
Created July 30, 2017 07:53
Show Gist options
  • Save odeblic/36124fff851474f6e48cdb9967b09e09 to your computer and use it in GitHub Desktop.
Save odeblic/36124fff851474f6e48cdb9967b09e09 to your computer and use it in GitHub Desktop.
To be tested...
#include <iostream>
#include <string>
#include <sstream>
int main(int argc, char ** argv)
{
std::string content;
std::stringstream buffer;
if (argc > 1)
{
//buffer.reserve(100000000);
content.reserve(100000000);
buffer.str(content);
buffer.seekg(0);
std::cout << "reserve memory" << std::endl;
}
std::cout << "size: " << buffer.str().size() << std::endl;
for(int i=1; i<=1000000; ++i)
{
buffer << "blabla" << i;
buffer << "zoozoo" << i + 2;
}
std::cout << "size: " << buffer.str().size() << std::endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment