Boost logo

Boost Users :

From: Jonathan Turkanis (technews_at_[hidden])
Date: 2005-04-10 13:45:35


CodeLogic wrote:
> Hi,

Hi,

Let me reorder your message a bit.

> I'm trying to use stringstreams in a tuple like

> ... give me the following error:
>
>
c:\.....\include\boost-1_32\boost\tuple\detail\tuple_basic_no_partial_spec.hpp(1
90):
>
>
> error C2558: class 'std::basic_stringstream<_Elem,_Traits,_Alloc>' :
> no copy constructor available or copy constructor is declared
> 'explicit' with
> [
> _Elem=char,
> _Traits=std::char_traits<char>,
> _Alloc=std::allocator<char>
> ]

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.

> fstream fin(filename.c_str(), ios_base::in);
> tuple<stringstream, stringstream, stringstream, stringstream> 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.

> I'm basically looking for a solution of being able to stream tuples
> with strings in the them in and out of a file.> Any suggestions will be
appreciated.

Do you mean you want to store and retrieve a tuple<sting, string, string,
string, ...>? You can't use operator>> for this, since it will use whitespace as
a separator, in addition to being sensitive to istream field widths.

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.

> Thanks !

Jonathan


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net