Discussion Overview
The discussion revolves around the practice of forward declaring templates in C++. Participants explore the implications, potential issues, and stylistic considerations associated with this practice, referencing various sources and guidelines.
Discussion Character
- Debate/contested
- Technical explanation
Main Points Raised
- One participant questions why leading C++ experts consider forward declaring templates to be bad style or dangerous.
- Another participant suggests an article that discusses declaration versus definition but finds it does not address the concerns about forward declaring templates.
- A participant cites Google's C++ style guide, stating that forward declaring a template can lead to code duplication and hinder compatibility changes.
- One participant challenges the reasoning provided by Google's style guide, proposing that authors can create separate headers for forward declarations and referencing the C++ standard library's practices.
- A later reply emphasizes that forward declaring templates can lead to undefined behavior, highlighting the risks of relying on specific compiler implementations.
- Another participant introduces the PIMPL idiom as a potential solution to the issues associated with forward declaring templates, explaining its structure and benefits.
Areas of Agreement / Disagreement
Participants express differing views on the appropriateness and implications of forward declaring templates, with no consensus reached on the best practices or reasoning behind the concerns.
Contextual Notes
Some participants reference specific guidelines and practices from the C++ standard library, but the discussion remains open-ended regarding the broader implications and best practices for forward declaring templates.