r/cpp • u/TheRavagerSw • Sep 20 '26
Self Contained Source Groups are amazing
I basically adopted this idea from Abseil (https://abseil.io/) and from this CppCon talk: https://youtu.be/re4Oy1IVj-s?si=3bwtKqOyMAX6WSAs.
I structure each source group in my projects like this:
src_grp/
├── iface/
│ └── smth.cppm
├── impl/
│ └── smth.cpp
├── inc_pub/
│ └── pub.hpp
├── inc_priv/
│ ├── priv.hpp
│ └── maybe.inc
├── test/
│ └── test.cpp
├── bench/
│ └── bench.cpp
└── docs/
├── some.md
└── doxygen.inI strongly recommend this approach over older project-wide conventions such as having a single global test/ or bench/ directory etc.
0
Upvotes
View all comments
Show parent comment
1
u/UndefinedDefined Sep 26 '26
It makes no sense to call them private then. Private means the user doesn't need them, and doesn't need transitive dependencies these headers depend on.
Just don't call them private headers then. They are not private if user needs them for whatever reason.