Hi Philip,
the problem is the cast from istream to bool which just doesn't work right with CINT. Use the explicit test with good() instead:
#include <sstream> #include <string> #include <iostream>
void cint_stringstream()
{
stringstream s("a b c");
string tmp;
while (s.good()) {
s >> tmp; cout << tmp << endl;
Cheers, Axel.
On 2008-03-31 18:33, Philip Rodrigues wrote:
> The following code snippet (attached as a macro), produces different
> results in interpreted mode and when compiled (with recent development
> root):
>
> stringstream s("a b c");
> string tmp;
> while (s >> tmp) cout << tmp << endl;
>
> For some reason, the "s >> tmp" evaluates to false one "step" too early
> in interpreted mode. Example session is below.
>
> dev pplxgenng:~> root -q cint_stringstream.C
> Processing cint_stringstream.C...
> a
> b
>
> dev pplxgenng:~> root -q cint_stringstream.C+
> Processing cint_stringstream.C+...
> a
> b
> c
>
> Regards,
> Philip
Received on Tue Apr 01 2008 - 16:04:20 CEST
This archive was generated by hypermail 2.2.0 : Tue Apr 01 2008 - 17:50:01 CEST