The first problem is that std::ostringstream
is non-copyable, and you are trying to create a copy of it while creating a copy of Buffer
.
The reason why you are creating a copy of Buffer
in this return
statement:
return Buffer(*this);
Is that your class Buffer
does not have an implicitly-generated move constructor. And the reason why it does not have one, is that Buffer
has a user-defined destructor, which inhibits the implicit generation of the move constructor.
You could define one explicitly:
Buffer(Buffer&& b)
:
mPar(b.mPar),
os(std::move(b.os))
{
}
But you should be aware of the fact that some implementations of the Standard Library are not fully compliant, and do not implement the move constructor of std::ostringstream
.