Exercise 12-5 in Accelerated C++.
My operator+= works:
void Str2::operator+=(const Str2& a)
{
iterator new_data = alloc.allocate((avail - data) + a.size());
iterator new_avail = std::uninitialized_copy(data, avail, new_data);
new_avail = std::uninitialized_copy(a.data, a.avail, new_avail);
uncreate();
data = new_data;
limit = avail = new_avail;
}
However i cant get the operator+ to work:(
Str2 operator+(const Str2& a, const Str2& b)
{
Str2 r = a;
r += b;
return r;
}
Error: Debug Assertion Failed!
Expression: _BLOC_TYPE_IS_VALID(pHead->nBlockUse)
Its probably something obvious.
Any help is appreciated!!