I was wondering if there is some way to tell the std::string
to release the char*
it is using.
I imagine that somewhere on the std::string
it has a field of type char*
, I was wanting some method that would to something like that:
const char* std::string::release() {
const char* result = __str;
__size = 0;
__capacity = INITIAL_CAPACITY_WHATEVER;
__str = new char[INITIAL_CAPACITY_WHATEVER];
return result;
}
Not that copying the content is a problem or will affect my performance, I just was felling uncomfortable with wasting time copying something that I am just going to delete after.