You can't create a tuple of stringstreams because basic_ios, which is a base class of stringstream, is non copyable. You should be able to create a tuple of references to stringstreams, though.
I see, my intention is to create tuples consisting of strings (strings or stringstream is immaterial for me, I used stringstream since they support io streams and I thought they would be more compatible when streaming tuples) and basically have the capability of streaming it in and out of a file.
fstream fin(filename.c_str(), ios_base::in); tuple
test; fin>>test; It's not clear what you're trying to do do here. If I saw this code in isolation, I'd guess you were trying to deserialize a tuple containing three strings.
This is my attempt of streaming a tuple from a file into the data struct. Maybe my code is incorrect :) ?
Do you mean you want to store and retrieve a tuple
? You can't use operator>> for this, since it will use whitespace as a separator, in addition to being sensitive to istream field widths.
If the whitespace factor is the only drawback, I can work around it by replacing whitespaces (which I actually doubt I will have in my strings) with some other character like an '_'. If there are no whitespaces should this work as expected?
You might try Boost.Serialization, although since I haven't used this library yet I don't know whether there is support for serializing tuples or whether you have to do it yourself. A simpler way would simply be to write the string to a file separated by a character which you know won't appear in any of the strings, if there is such a character.
From what I read in the tuples documentation, tuples supports streaming out of the box: http://www.boost.org/libs/tuple/doc/tuple_users_guide.html#streaming I figured as long as I use fields that themselves supports streams (like stringstream), it should work fine. But however, in the end, what I need is the ability to save tuples (consisting of strings and assuming there are no white spaces within each string) into a file and reload it when necessary. Thanks a lot for your response ! CodeLogic.