The more I learn about C++ the less sense it makes to me that the C++ standard library source code (where all those std
functions are implemented) makes heavy use of variable names with __
prefix. Like std::addressof()
uses __r
as its single argument. I tried to get meaningful answers why this is the case (even asked ChatGPT!) but no luck. I know that __
prefix is reserved and user code cannot use such names. But how could user code collide with, say, the argument name of a function in std
?! That's what's puzzling to me. Same goes for private members in std
. Even local variables start with the __
prefix! What's the point of using __
prefix in those cases? It's almost like the standard library implementers are suggesting through their practice that somehow hiding implementation details from user code depends on this convention. That, without this practice, users could somehow rely on those names that 'were not intended for them'.
By the way, this makes C++ standard library source code much harder to read. Maybe intentionally so?