http://www.lmgtfy.com/?q=stringstream+c%2B%2B
In parole povere, lo stringstream è uno stream che invece di scrivere l'output su un file o sullo schermo te lo fornisce sotto forma di stringa (ottenibile richiamando appunto il metodo str()).
In ogni caso l'ultima soluzione di shodan è un pelo più efficiente.