home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.c++.moderated      Moderated discussion of C++ superhackery      33,346 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 32,444 of 33,346   
   DeMarcus to All   
   Re: C++ Library design: public header fi   
   02 Jul 12 12:42:11   
   
   From: use_my_alias_here@hotmail.com   
      
   { Please limit your quoting the minimum needed to establish context   
      -mod }   
      
   On 2012-07-02 20:07, fmatthew5876 wrote:   
   > { Please limit your text to fit within 80 columns, preferably around   
   >    70, so that readers don't have to scroll horizontally to read   
   >    each line.  This article has been reformatted manually by the   
   >    moderator. -mod }   
   >   
   > When developing a C++ library, the most common idiom is to have a   
   > separate header file for each class. The user can then only include   
   > the headers for the classes they want to use and thus reduce compile   
   > times. The disadvantage is that the user has to do a lot of includes   
   > if they are commonly using many different classes together in   
   > different source files.   
   >   
   > However, in some C libraries, the idiom is to #include a single   
   > header file to get the entire library or there may be a couple of   
   > header files for each subsystem. If the user is expected to use a   
   > set of classes together most of the time this may make more   
   > sense. Consider a math library with vec2, vec3, vec4, mat2, mat3,   
   > mat4, etc.. One header per type can quickly get unwieldy.   
   >   
   > So what approach do you all typically prefer? Per class? Per   
   > subsystem?  Some combination?   
      
   I'd say per class. Everything else is just non-intuitive to search in.   
   If you have vec2, vec3, vec4, then that may be an exception until you   
   have rewritten it with templates, but don't mix vec2 and mat2.   
      
   When it comes to free functions you can have a group of functions in   
   the same header as long as they have a domain connection. Don't be   
   afraid to split that header into sub-domains, it helps you remove   
   dependencies.   
      
   Regards,   
   Daniel   
      
      
      
      
   --   
         [ 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)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca