Reputation: 5178
I am processing several chunks of byte arrays (uint_8
) and append them to a string (my_string
). For efficiency purposes, I have reserved more than enough bytes for my string by
my_string.reserve(more_than_enough_bytes);
I am trying to append each chunk as shown in the following function:
bool MyClass::AppendToMyString(uint_8* chunk, size_t chunk_num_bytes) {
memcpy(const_cast<uint_8*>(my_string.data()), chunk, chunk_num_bytes);
return true;
}
But the problem is that memcpy
does not update my_string
size. So, next time when this function is called, I do not where the last element was, other than using a separate variable for it. Any ideas?
Upvotes: 1
Views: 4802