[namespace.constraints] (original) (raw)

16 Library introduction [library]

16.4 Library-wide requirements [requirements]

16.4.5 Constraints on programs [constraints]

16.4.5.2 Namespace use [namespace.constraints]


16.4.5.2.1 Namespace std [namespace.std]

16.4.5.2.2 Namespace posix [namespace.posix]

16.4.5.2.3 Namespaces for future standardization [namespace.future]


16.4.5.2.1 Namespace std [namespace.std]

Unless otherwise specified, the behavior of a C++ program is undefined if it adds declarations or definitions to namespacestdor to a namespace within namespacestd.

Unless explicitly prohibited, a program may add a template specialization for any standard library class template to namespacestd provided that

The behavior of a C++ program is undefined if it declares an explicit or partial specialization of any standard library variable template, except where explicitly permitted by the specification of that variable template.

[Note 1:

The requirements on an explicit or partial specialization are stated by each variable template that grants such permission.

— _end note_]

The behavior of a C++ program is undefined if it declares

A program may explicitly instantiate a class template defined in the standard library only if the declaration

Let F denote a standard library function ([global.functions]), a standard library static member function, or an instantiation of a standard library function template.

Unless F is designated an addressable function, the behavior of a C++ program is unspecified (possibly ill-formed) if it explicitly or implicitly attempts to form a pointer to F.

Moreover, the behavior of a C++ program is unspecified (possibly ill-formed) if it attempts to form a reference to _F_or if it attempts to form a pointer-to-member designating either a standard library non-static member function ([member.functions]) or an instantiation of a standard library member function template.

Let F denote a standard library function or function template.

Unless F is designated an addressable function, it is unspecified if or how a reflection value designating the associated entity can be formed.

[Note 3:

For example, it is possible that std​::​meta​::​members_ofwill not return reflections of standard library functions that an implementation handles through an extra-linguistic mechanism.

— _end note_]

Let C denote a standard library class or class template specialization.

It is unspecified if or how a reflection value can be formed to any private member of C, or what the names of such members may be.

A translation unit shall not declare namespace std to be an inline namespace ([namespace.def]).

16.4.5.2.2 Namespace posix [namespace.posix]

The behavior of a C++ program is undefined if it adds declarations or definitions to namespaceposixor to a namespace within namespaceposixunless otherwise specified.

The namespace posix is reserved for use by ISO/IEC/IEEE 9945 and other POSIX standards.

16.4.5.2.3 Namespaces for future standardization [namespace.future]

Top-level namespaces whose namespace-name consists of stdfollowed by one or more digits ([lex.name]) are reserved for future standardization.

The behavior of a C++ program is undefined if it adds declarations or definitions to such a namespace.

[Example 1:

The top-level namespace std2 is reserved for use by future revisions of this International Standard.

— _end example_]