Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

should stringbuf positioning fail after the sequence is fully read?

23 views
Skip to first unread message

Pavel

unread,
Jan 18, 2015, 8:34:53 PM1/18/15
to
Should the code below print 1 or -1? I think -1, but the standard library
implementations I tried printed 1; who is right and why?

Thanks in advance,
-Pavel

#include <iostream>
#include <sstream>

using namespace std;

int main(int, char*[]) {
const string s(1, 'A');
istringstream iss(s);
char c;
iss >> c;
cout << iss.rdbuf()->pubseekoff(0, ios_base::cur, ios_base::in) << endl;
return 0;
}
0 new messages