Boost logo

Boost Users :

From: Ovanes Markarian (om_boost_at_[hidden])
Date: 2007-07-28 02:27:47


On Sat, July 28, 2007 00:07, Bill Lear wrote:
[...]
>
> Well, stringstream defines a type, from g++ header:
>
> typedef basic_string<char_type, _Traits, _Alloc> __string_type;
>
> and str() is defined to return this:
>
> __string_type str() { ...}
>
> So, if I have a std::string, and an ostringstream with a different
> allocator, say my_ostringstream, I cannot do this:
>
> my_ostringstream os;
> os << ...;
> std::string s = os.str();
>

Ok, but you understand that this approach, will probably consume twice as much memory, since str()
leaves stream as it is and does not remove characters read. A was meaning this:

       my_ostringstream os;
       os << ...;
       std::string s;
       os >> s;

And this should work with custom allocators in stringstream and string.

With Kind Regards,

Ovanes Markarian


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