String streams can take a string object as an argument, provided either as an argument to the constructor, or set later through the member function str(const basic_string <char_type, traits_type, allocator_type>&). This string is copied into an internal buffer, and serves as source or sink of characters to subsequent insertions or extractions. Each time the string is retrieved through the str() member function, a copy of the internal buffer is created and returned.
Output string streams are dynamic. The internal buffer is allocated once an output string stream is constructed. The buffer is automatically extended during insertion each time the internal buffer is full. (This is different from old iostreams, which allowed both dynamic and static output streams. See for Section 45.4 further details.)
Input string streams are always static. You can extract as many items as are available in the string you provided the string stream.