This is the mail archive of the libstdc++@sourceware.cygnus.com mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

re: basic_streambuf<> and copying



  basic_streambuf<> contains a lot of pointers but it does not
  prohibit the copying.  What does the standard say about the copying
  of basic_streambuf<>?

No explicit copy ctors or assignment operators for basic_streambuf,
basic_stringbuf, or basic_filebuf are in the standard. This is pretty
normal, as is stated here:

17.3.2.2 Functions within classes

For the sake of exposition, clauses 18 to 27 do not describe copy
ctors, assignment operators, or (non-virtual) dtors with the same
apparent semantics as those that can be generated by the default.

By not explicitly excluding these member functions, the standard
implies that one should be able to copy these around. I, for one,
don't see the sense in copying filebufs around, in particular. Maybe
that's just me though. Anybody care to clue me in?

Bjarne doesn't address this in CPL v3, libstdc++-v2 allows copying,
and streambufs in particular haven't come up on the library issues
list, although basic_ios and ios_base appear to have a similar
ambiguity:

50.  Copy constructor and assignment operator of ios_base
(trying to figure out if ios_base is copy-able)

That being said, with all the pointers in basic_streambuf, we are left
with two options:

1) it may indeed be wise to make the assignment operators/copy ctor
private, which would prohibit copying and is not conformant to the standard.

2) make deep copies, no matter how painful this.

It looks like #2 is what should be done: comments?

-Benjamin



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]