2011/10/7 Jon Cruz <jon@...18...>:
On Oct 6, 2011, at 12:49 PM, Krzysztof KosiĆski wrote:
Writing forward declarations for template types such as std::ostream is non-trivial, and in fact the declarations are often an implementation detail. The same is the case for Geom::Rect. This is why we have <2geom/forward.h> - to allow the library to provide its forward declarations, rather than the user, so that people might use Geom::Rect const & without having to include the entire definition of this type or writing 2Geom implementation details in their headers. <2geom/forward.h> is not broken.
Ah, this is actually a good point, and highlights what I mean.
If one wants to use Geom::Rect, one can just include <2geom/rect.h>. For more complex declarations, especially templates, it is often the most efficient way. To have something else, such as merely a complex forward declaration, we'd usually need some measured performance gain to adding it. For simple types, then forward declarations in a independent file most often do not bring much.
Additionally, for types used by other headers in a library one can just have those library headers use their own forward declarations. Then a user automatically gets the ones they might need pulled in for free, and don't need to explicitly ask for things.
For the simple case, having a <2geom/2geom.h> that pulls in everything makes it simple to use.
Also... we often find in analyzing code that something attempting an optimization via forward declare headers actually ends up pulling in the full headers anyway. So any intended compilation benefit is lost, and only an extra include gets added.
Can this discussion die in a fire please? Johan & Krzysztof have expressed their desire to not modify 2geom in the way that Inkscape has recently been modified. Given that 2geom is a separate project and they are probably currently the 2 most active members working on it, it seems like the discussion is done since you did what you felt was best for Inkscape and we don't modify our in-tree copy of 2geom as a policy.
Cheers, Josh
P.S. This is where Johan and I are so on-page with each other... if people put half the time into coding that they did into other things like useless discussion and whitespace cleanup of files they didn't already happen to be working on, we'd be so much further along.