Is it possible to assign a buffer to a stringbuf - stringstream? It would be worthwhile ?

How can I assing a buffer to a stringbuf - stringstream ?
( What are the difference betwen them ? I keep on understanding )


If I put data in it , in example 1000000 times, 8 bytes (8000000 bytes), streambuf-stringstream assign continuosly new memory ?
It would be worthwhile to assign a char buffer of 8000000 ? Are the process to be faster ?

Now I have :

1
2
3
4
5
6
char myybuffer [65536];
     stringstream ss;
     ss.rdbuf()->pubsetbuf(myybuffer,65536);
     for (int i=0;i<100000;i++)
     ss.write ( reinterpret_cast<char*>(&a_double ), sizeof a_double );
     


I have not noticed any improvement if I use or not the rdbuf assing.

Thanks
Topic archived. No new replies allowed.