title: Managing forward declarations
body: <p>It's well known that using forward declarations is preferable to using #includes in header files, but what's the best way to manage forward declarations?</p>
  
  <p>For a while, I was manually adding to each header file the forward declarations that were needed by that header file.  However, I ended up with a bunch of header files repeating the same half-dozen or so forward declarations, which seems redundant, and maintaining these repeated lists got to be a bit tedious.</p>
  
  <p>Forward declarations of typedefs (e.g., <code>struct SensorRecordId; typedef std::vector&lt;SensorRecordId&gt; SensorRecordIdList;</code>) is also a bit much to duplicate across multiple header files.</p>
  
  <p>So then I made a <code>ProjectForwards.h</code> file that contains all of my forward declarations and included that wherever it was needed.  At first, this seemed like a good idea - much less redundancy, and much easier maintenance of typedefs.  But now, as a result of using <code>ProjectForwards.h</code> so heavily, whenever I add a new class to it, I have to rebuild the world, which slows development.</p>
  
  <p>So what's the best way to manage forward declarations?  Should I bite the bullet and repeat individual forward declarations across multiple subsystems?  Continue with the <code>ProjectForwards.h</code> approach?  Try to split <code>ProjectForwards.h</code> into several <code>SubsystemForwards.h</code> files?  Some other solution I'm overlooking?</p>