I wrote a program in C++ using Visual Studio on my desktop. In that environment, the program compiles and executes without error, and the output is exactly as expected.
However, when I try to move my source code to a linux system and compile it, the I encounter errors related to my use of stringstream. The code has the form:
#include <sstream>
#include <string>
using namespace std;
int main() {
string line;
stringstream ssline;
ssline = stringstream(line); //where the error occurs
}
I use this assignment operation many times throughout my program, and like I said - I didn't cause any problems when I used Visual Studio to compile. On my linux system, both the gnu compiler and the intel compiler throw the same error, which reads:
ProgramName.cpp:73:12: error: use of deleted function
‘std::basic_stringstream<char>& std::basic_stringstream<char>::operator=
(const std::basic_stringstream<char>&)’
ssline = stringstream(line);
^
In file included from ProgramName.cpp:13:0:
/usr/include/c++/4.8.2/sstream:502:11: note:
‘std::basic_stringstream<char>& std::basic_stringstream<char>::operator=(const std::basic_stringstream<char>&)’
is implicitly deleted because the default definition would be ill-formed:
class basic_stringstream : public basic_iostream<_CharT, _Traits>
I do not know what to make of this error, nor why it seems to be system dependent. I can rewrite my source code to avoid the use of stringstream, but I would prefer not to. Because again, I know it works on my desktop environment.
I appreciate any help that can be offered in resolving this difficulty.
Thanks in advance.
HolyBlackCat :
It seems that GCC has move assignment for std::stringstream since GCC 5, and you use GCC 4.8.2.\n\nYour GCC is too old, you need to upgrade.",
2018-07-27T16:50:27