Namespaces 101
summary
Covers namespace syntax and evolution with dates: C++98 namespaces, C++11 inline namespaces, C++17 nested namespace openings and C++20 nested inline openings. Explains qualified vs unqualified lookup and argument dependent lookup (ADL) with concrete examples showing when AB::x resolves, when unqualified lookup climbs scopes, and how ADL finds functions by argument types. Demonstrates hazards: using-directive pollution creating ambiguities, macros escaping namespaces, and shows practices from Core Guidelines and Google: avoid using namespace std in headers, prefer using-declarations in .cpp, use inline namespaces only for versioning.
AI-written summary · about
chapters (7)
- 0:00Introduction to namespaces
- 2:43Understanding namespaces
- 7:20Evolution of namespaces
- 15:34Namespace mechanics
- 34:46Namespace scope and pollution
- 51:33Anonymous namespaces
- 53:03Best practices
related talks
51mArgument dependent lookup (ADL): name taxonomy, customization points & use cases
59mC++20 - My Favourite Code Examples
01h 34mC++11/14 at Scale - What Have We Learned?
01h 32mA Medley of C++
03mKeyword Abuse
01h 02mC++20 - My Favourite Code Examples
59mC++17 in Breadth (part 1 of 2)
01h 36mBuilding C++ Interfaces That Are Hard to Use Incorrectly
