This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: cin/cout as reference objects [Re: AIX I/O failures]
On Thu, Jan 25, 2001 at 07:06:50PM -0800, Mark Mitchell wrote:
> What you say, though, applies to the *original* approach as well, so
> we're no better off than we were then, if I understand correctly.
Yes.
> But, that doesn't really do any good, because there are inline
> functions on ostreams anyhow, and because users can say `sizeof
> (cout)' in their programs, and if the library implementors change the
> size of the stream, those folks are going to be hosted anyhow,
> regardless of the shared object/linker thing, right?
Depends on what that sizeof is used for. Can you think of any
legitimate uses?
More to the point, suppose at some point in the future you want to make
the implementation for cout be some subclass of ostream. If you export
cout as an object, this isn't possible unless the subclass is exactly
the same size. If you export cout as a reference, you're golden.
This has happened several times in glibc's history in extending stdio
to cope with new requirements. What are the odds this won't eventually
be needed for c++ as well?
r~