I have a class that has a std::stringstream member:
class Buffer
{
std::stringstream ss_;
};
Its move constructor is
Buffer::Buffer(Buffer&& buf)
: ss_(std::move(buf.ss_))
{
}
I suspect that the move operation will not throw and the move constructor could be noexcept because of this. So my questions are:
- How do I determine if a function from the STL is declared
noexcept, for examplestd::stringstream::str? - If swapping or moving the
stringstreamwas notnoexcept, could I still declare theBuffermembersnoexceptand get a call tostd::unexpected()if an exception is thrown by thestringstream? From what I can find that would be the case. - Is there a way around the problem, for example an alternate container that can be written to using the stream operators and that is
noexcept?
Aucun commentaire:
Enregistrer un commentaire