3

In C++, I need to make streams of objects which are of non-POD type using my own implementation of std::basic_streambuf<Type>. Is the standard library required to construct/destroy the objects when expected?

Hristo Venev
  • 972
  • 5
  • 17
  • I'm not so sure. You don't usually see `std::basic_streambuf`. – Puppy Nov 19 '12 at 12:09
  • @DeadMG: oh sorry, I misunderstood the question then :) I deleted my comment to avoid confusion – jalf Nov 19 '12 at 12:14
  • Yes, is the only answer I can imagine for this one. Although it does rather depend on what you mean by 'expected'. – john Nov 19 '12 at 12:30
  • 3
    All I can see so far is 27.2.2:2 *In the classes of Clause 27, a template formal parameter with name charT represents a member of the set of types containing char, wchar_t, and any other implementation-defined character types that satisfy the requirements for a character on which any of the iostream components can be instantiated.* Hmm, not very helpful... – atzz Nov 19 '12 at 12:32
  • I don't know how Meaningful it is, you may want to serialize, you need to specialize `std::char_traits` and `std::allocator` for your `T`. but there better ways to serialize – Neel Basu Nov 19 '12 at 13:19

1 Answers1

0

It is possible, but you might need to implement some missing iostream, char_traits, members/friend functions. Some basic functionality like ostream::write might work out of the box.

Basilevs
  • 22,440
  • 15
  • 57
  • 102