The external specification of the class std::strinstream does not claim that the object std::strinstream is stored inside the object std::strinstream . Therefore, we should not expect that you will be able to “pick up” the contents of std::strinstream in std::string with the help of move semantics.
That is, in the general case, it will not be possible to get rid of the stage of building the object std::string based on the current contents of std::strinstream .
The std::strinstream::str() method returns its result by value. If, when implementing this method, the compiler applies return value optimization (RVO), then the result ss.str() will be constructed directly in your object s . Otherwise, a temporary object of type std::string will be constructed and returned, which you will already take to your s using move semantics. This is probably the only place where move semantics can work.
PS In the light of the above, it is clear that you cannot achieve anything by working with ss.str() "directly." To do this, you still have to construct the result ss.str() . And therein lies the problem, i.e. it saves nothing.
std::stringstreamimpractical. - ixSci