On Fri, Feb 14, 2003 at 01:43:50PM +0000, Angus Leeming wrote: > why does this compile: > string data = ...; > istringstream datastream(data); > LyXLex lex(0,0); > lex.setStream(datastream); > > and this not: > LyXLex lex(0,0); > lex.setStream(istringstream(data)); > > The compiler complains that it is expecting a std::istream & and got a > std::stringstream. Is it an lvalue thing? (passed & not const & so I guess > that the stream is modified...)
The stream has to be modifiable, otherwise you won't be able to wrtie to it. istringstream(data) creates a temporary object which cannot be bound to a non-const ref. I personally think this is a stupid restriction, but Those Who Know decided otherwise. Using an explicit temporary variable is the accepted way to handle this... Andre' -- Those who desire to give up Freedom in order to gain Security, will not have, nor do they deserve, either one. (T. Jefferson)