I have the following piece of code that surprised me (using libstdc++4.8)...
#include <iostream>
#include <sstream>
#include <string>
using namespace std;
int main() {
std::string s("some content");
std::stringstream ss(s, std::ios::in|std::ios::ate);
std::istream& file = ss;
//ss.clear(); Makes no difference...
std::cout << "tellg() pos: " << file.tellg() << std::endl;
return 0;
}
... which has the following output.
tellg() pos: 0
This behaviour is different to when using std::ifstream(std::ios::ate).
- Is this behaviour correct/expected?
- Does one need to explictly seekg(0, std::ios::end) despite opening with ate?
- clearing the state doesn't make a difference.
- Please note that the string has content.