Reserved Names in the Global Namespace

Arises from my answer to a Dynamic Array of Objects in C ++ and according to What are the rules for using the underscore in a C ++ identifier? : Apparently, names starting with _followed by an uppercase letter are reserved in the global namespace.

17.4.3.2.1 Global Names [ lib.global.names]

Certain sets of names and function signatures are always reserved for implementation:

  • Each name that contains a double underscore ( __) or begins with an underscore followed by an uppercase letter (2.11) is reserved for implementation for any use.
  • Each name starting with an underscore is reserved for implementation for use as a name in the global namespace. 165

165) Such names are also reserved in the namespace ::std(17.4.3.1).

In my answer to the first question, I had a class similar to this

class A
{
 private:
   vector<int> _Ints;
}

In the comments, they told me that the identifier _Intscauses undefined behavior, since this is a reserved name. However, according to a recent draft of the standard, the search for the name of a member variable occurs according to the following rule:

3.4.3.1 Members of the class [ class.qual]

, , , (10.2), , .

, - , .

, :

, - , ? , - ?

+5
3

_Int : " , (_ _) , (2.11) "." " , : - , - , . , , , undefined ( ).

, , , , , , . , . (, , . , linux 1. , ... , , .)

, .

+6

, , , , , , . - _Ints .

, , , . , , , - _Ints, _Ints, .

+2

-, _ ( Upercase) .

No. It is reserved everywhere . Read 17.4.3.2.1 again:

Each name that contains a double underscore (_ _) or begins with an underscore followed by an uppercase letter (2.11) is reserved for implementation for any use.

This does not mention the โ€œglobal namespaceโ€ at all (the global namespace is applicable only in the next rule).

+1
source

All Articles