#include <iostream>
#include<vector>
#include<sstream>
int main()
{ std::vector<std::stringstream> X;
X.resize(10);//comment out this line and it will compile
return 0;
}
This does not compile (gcc latest version, Ubuntu, default code::blocks project settings). Can anyone explain why? Help appreciated!
tition
P.S. This problem really ticked me off: I am really annoyed for losing my time with this!
In C++03 the elements stored in the vector must be copyable. I don't think std::stringstream is copyable so that could be it.
In C++11 it's enough if the elements in the vector are movable. std::stringstream is movable so it should work for sure. Not sure how up to date GCC is on this though.
I moved away from using std::stringstream so that fixed my problem: thanks for the explanation!
I want to complain that gcc's error message was completely insane, like 1 screen long, and it didn't indicate that X.resize(10) caused the problem. As I had made a bunch of other small changes, it took me forever to locate the exact cause of the problem (had to comment out each piece of new code till I found the real cause of the problem).