Not logged in, Join Here! or Log In Below:  
News Articles Search    

 Home / General Programming / strtream compile prob Account Manager
Archive Notice: This thread is old and no longer active. It is here for reference purposes. This thread was created on an older version of the flipcode forums, before the site closed in 2005. Please keep that in mind as you view this thread, as many of the topics and opinions may be outdated.
Brent Arias

April 14, 2005, 04:33 PM

About a week ago I had made a piece of code that looked something like this:

  2. (strstream() << "foo").c_str();

The idea is to make an anonymous instance of the strstream class, stream some stuff into it, and then immediately get the ascii string representation of its internal buffer. It didn't compile. Anyone know why?



April 14, 2005, 04:40 PM

Explicit constructor calls are not allowed:

strstream ()

is not syntactically valid. You need to provide a name as in

strstream x ()

of course it isn't anonymous any longer.

Even then

(strstream x ())

Chad Austin

April 14, 2005, 04:55 PM

I assume you're using VC++. That code should work in gcc, but there is a VERY strange rule in the C++ standard that says that anonymous temporaries have type T& but are *not* lvalues. Search for GLTEXT_STREAM in to see the bit of magic I went through to make it work. Keep in mind that the expression (strstream

This thread contains 3 messages.
Hosting by Solid Eight Studios, maker of PhotoTangler Collage Maker.