|
Boost Users : |
From: Ovanes Markarian (om_boost_at_[hidden])
Date: 2007-07-27 17:33:21
On Fri, July 27, 2007 23:11, Bill Lear wrote:
> On Friday, July 27, 2007 at 22:49:22 (+0200) Ovanes Markarian writes:
>>Most of std classes support custom allocators. basic_stringstream and
>>vector do this as well. You can preallocate the memory needed and
>>create objects in this memory locations. For more help see the
>>placement new operator.
>
> Hmm, yes, they do, but they also have a pitfall. If I create a new
> templated ostringstream with a custom allocator, it then means that
> the string that is returned also must use this custom allocator,
> and is incompatible with standard strings. I guess that's not
> surprising, however, now that I think about it...
>
I don't think it is so. std::string and a stream class are containers of elements. How they
contain them is their own beer. They exchange them for example via operators << and >> where it is
defined how the strings are serialized or deserialized to the stream. In these operators you
provide as template params Elems stored in stream and traits about these Elems. And the rest is
how you handle it.
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