But the point is, now we know the terms sink and source. A stringstream can be used either way. When you use it as a source, you're usually not happy with the stream's state because you forget what the stream already has: what you put into it when it was acting like a sink.
Every character is important to the stream. Either you will extract everything and set the stream pointer to indicate a state of emptiness though the interface (operator>>), or you will discard the stream itself and... set the stream pointer to indicate emptiness, through the interface (e.g. clear() ).
My conclusion is, you need to find a default way of operating, like cout, yourself. Maybe you can parse smarter so that it is impossible to be confused like you are in this thread. After all, enums have a defined syntax. There are a number of quick fixes, like clearing exactly where you need to, but I think you need to give real attention to the algorithm.
I mean, I sort of get what it takes to parse an enum:
Find and store an enum keyword.
Find and store an optional identifier.
Counted the opening brace.
Recursively parse the constant=value, expression
Balance the closing brace.
Find a sequence point ( ';' ).