r/cpp • u/According_Leopard_80 • Apr 09 '26
Writing only decoupled code
https://middleraster.github.io/DAG/HeaderOnlyNoForwardDeclarations.html
12
Upvotes
r/cpp • u/According_Leopard_80 • Apr 09 '26
View all comments
Show parent comment
1
u/ABlockInTheChain Apr 13 '26
If you read Google's style guides they point out problems that can occur when you forward declare templates and do not occur when you forward declare non-template types types, then point out all the problems that are caused by never forward declaring anything, then conclude that the solution is to never forward declare anything.
The alternative solution of banning forward declaration of template types while allowing it for non-template types was apparently never considered.