= m_length < newSize ? m_length : newSize;
char *copy = new char[newSize];
for (size_t i = 0; i < copyUntil; ++i)
copy[i] = m_str[i];
delete [] m_str;
m_str = copy;
you can do like this and avoid copying twice .
I had thought about this, but feared that it won't work 😅
Обсуждают сегодня