From: news.x.richarddamon@xoxy.net   
      
   On 2/18/12 4:37 PM, Martin B. wrote:   
   > Hi there!   
   >   
   > I was wondering why only the types get a header.   
   >   
   > Wouldn't it make sense to provide <...fwd> headers for many of the std   
   > headers? (e.g. or somesuch?)   
   >   
   > Has it ever been considered?   
   >   
   > cheers,   
   > Martin   
   >   
      
   > From what I remember hearing when the standard was forming (as an   
   outsider listening to discussions), the iosfwd header was put in to   
   resolve concerns for the compile time costs of some changes to the   
   library when templates were being fully implemented. In early C++   
   programs, many classes would implement a version of   
      
   ostream& operator<<(ostream&, myclass&)   
      
   to allow output. Originally ostream was just an ordinary class, so   
   rather than including iostream.h, the head could just have a line   
      
   class ostream;   
      
   and have a proper declaration. When it was proposed that streams be   
   converted into templates, this suddenly became more difficult,   
   especially since, for various reasons, the standard allowed additional   
   template parameters to exist as long as they all had defaults. This   
   meant that the user could NOT just right a proper declaration for   
   ostream in his header. Since also many files might not actually need   
   details of ostream, but could work with just the equivalent of class   
   ostream, the compile time cost of including a full version of iostream   
   was considered excessive.   
      
   For other headers, like in the "STL", there, one, wasn't the body of   
   code using it that expected to be able to cheaply provide the empty   
   declaration (after all, these WERE headers to define template classes),   
   and there was a lot less code that could actually benefit from having   
   just a forwarded declaration of the class.   
      
   Based on the effort to build these headers for not much benefit, the   
   committee decided not to require them to be available. Note that the   
   standard does NOT prohibit an implementation from documenting and   
   providing such a header, it just won't be a "standard header". The lack   
   of this being a popular extension provided shows that the vendors   
   generally agree that there isn't the need for it.   
      
      
   --   
    [ See http://www.gotw.ca/resources/clcm.htm for info about ]   
    [ comp.lang.c++.moderated. First time posters: Do this! ]   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|