Can the std::string capacity be changed to optimise it?
For example:
std::string name0 = "ABCDEABCDEABCDEF"; int cap = name0.capacity(); //cap = 31 int size = name0.size(); //size = 16 Okay, this is perfectly fine for a couple of strings in memory, but what if there are thousands? This wastes a lot of memory. Isn't it then better to use char* so you can control how much memory is allocated for the specific string?
(I know some people will ask why are there thousands of strings in memory, but I would like to stick to my question of asking if the string capacity can be optimised?)
shrink_to_fit(): en.cppreference.com/w/cpp/string/basic_string/shrink_to_fitcharfootprint. You won't get the footprint reduced below that size.