Howdy,
From time to time, I find myself in a situation where a code reviewer
suggests to replace #include <QFoobar> with the corresponding class
forward declaration. Such discussions usually get us nowhere because
neither the code reviewer nor I mind to seek for a compromise. A policy
would prevent wasting time on such discussions.
Note that I used Qt/QFoobar only as an example. Similar logic can be
applied to other libraries as well. For example, libxcb or libexif, etc.
The good thing about forward declarations is that they can reduce the
compilation time quite significantly.
The bad thing about it is that we must guarantee that the definition of
QFoobar in the external library won't change. For example, QFoobar won't
move into an inline namespace all of sudden, etc.
I propose to add a paragraph in [1] saying whether it is okay to add
forward declarations for things from external libraries.
Any thoughts or suggestions?
Cheers,
Vlad
https://community.kde.org/Policies/Library_Code_Policy#Avoid_including_other_headers_in_headers