std::string
has a .reserve
method for pre-allocation.
std::string s;
s.reserve(1048576); // reserve 1 MB
read_file_into(s);
More Related Contents:
- how to change to c code while using for loop and array
- How to convert an instance of std::string to lower case
- C++ Convert string (or char*) to wstring (or wchar_t*)
- What are the mechanics of short string optimization in libc++?
- Remove spaces from std::string in C++
- Why should one not derive from c++ std string class?
- Convert string to variable name or variable type
- Check if a string contains a string in C++
- How do I check if a C++ string is an int?
- Find out if string ends with another string in C++
- Case insensitive std::string.find()
- Convert String containing several numbers into integers
- C++ string::find complexity
- Is it reasonable to use std::basic_string as a contiguous buffer when targeting C++03?
- How to change string into QString?
- Implicit conversion from char** to const char**
- How to rearrange a string equation?
- How to pass a vector of strings to execv
- Copy a streambuf’s contents to a string
- Issue with cin when spaces are inputted, using string class
- std::vector to string with custom delimiter
- Convert string to mathematical evaluation [closed]
- Convert char * to LPWSTR
- What is the difference between string::at and string::operator[]?
- When did C++ compilers start considering more than two hex digits in string literal character escapes?
- What is the simplest way to convert char[] to/from tchar[] in C/C++(ms)?
- How to write an object to file in C++
- convert string to integer in c++
- How to convert int to string in C++
- Assign a string literal to a char* [duplicate]