I would like to do this
MyClass x;
istringstream("XXX") >> x; // Works in VC++ but not GCC
instead of
MyClass x;
istringstream iss("XXX");
iss >> x; // Works in both GCC and VC++
In other words I would like to be able to use istringstream without
having to declare (and name) an object for the stream. This works fine
in VC++ but not in GCC. It appears that it fails to compile in GCC
because the copy constructor for ios_base is private.
The strange thing is that GCC will compile this like I want if the type
I'm extracting into is a native type instead of a user defined type.
double x;
istringstream("10.4") >> x; // Works in both GCC and VC++
compiles and works in GCC. Is what I want to do legal use of
istringstream? Is there anything I can do to classes I define to make
this work in GCC? It's really annoying to have to declare a variable
with a name when I just want to extract some value from a string.
Thanks,
Ryan