This is the mail archive of the libstdc++@gcc.gnu.org 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: breaking compatibility


On Thu, Apr 19, 2001 at 11:30:12AM -0700, Loren Osborn wrote:
> The first problem I'm having is that I can no longer forward declare
> istream as:
> 
>   class istream;
> 
> since it is now declared as:
> 
>   typedef class std::basic_istream<char, std::char_traits<char> > istream;
> 
> The easiest work around I can think of for this problem would be to,
> instead, declare istream:
> 
>  class istream : public std::basic_istream<char, std::char_traits<char> >
>  {};

This alternative was carefully considered during standardization.
If there were any way it, or something like it, could have been 
approved instead, to preserve code with forward declarations, it 
would be in the standard now.  <iosfwd> was the best that could 
be done.

The standard doesn't say anything about <iostream.h> or <istream.h>,
so those could legally have a struct istream; but then they would be 
incompatible with the <iostream> and <istream> headers -- you would 
have to convert your programs and libraries all at once, without mixing.

Probably you will have to use #ifdefs, and relax the restriction on
including standard headers for the case of <iosfwd>.

Nathan Myers
ncm at cantrip dot org


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