r/cpp • u/tartaruga232 MSVC user, r/cpp_modules • Apr 26 '26
Code Examples From an App Using C++ Modules
https://abuehl.github.io/2026/04/26/code-examples-from-an-app-using-modules.htmlThis demonstrates usage of our recommendations for using modules:
- Prefer small modules
- Only use partitions if you really must
- Avoid using internal partitions
The intention is to show some real code for context of discussions about using C++ modules.
My goal is not to sell modules. If you prefer not using modules: Use header files. There are good reasons to continue using them.
For me, C++ source code is an asset. The intrinsic value of code using modules is higher (lower entropy), as modules are a higher abstraction, compared to header files, which are basically just the pasting of C++ code into translation units (I've done that for ~36 years now).
Using C++ modules comes at a cost though. Understanding modules requires a certain level of understanding, which isn't needed when using the simple model and tradition of header files.
View all comments
Show parent comment
4
u/not_a_novel_account cmake dev Apr 27 '26
You should basically never write
using namespace <anything>in global namespace scope. The entire purpose of namespaces is to avoid lookup ambiguities and your complaint reduces to "if I short-circuit the mechanism for avoiding name lookup ambiguities, then controlling declaration availability is necessary to avoid ambiguity."Which is true, you're 100% correct. However, your answer is to introduce better controls over declaration availability, and C++'s design is to encourage you not to short-circuit the namespace mechanism carelessly.
Inevitably, you're feeling this friction.