[namespace.constraints] # 16 Library introduction [[library]](./#library) ## 16.4 Library-wide requirements [[requirements]](requirements#namespace.constraints) ### 16.4.5 Constraints on programs [[constraints]](constraints#namespace.constraints) #### 16.4.5.2 Namespace use [namespace.constraints] #### [16.4.5.2.1](#namespace.std) Namespace std [[namespace.std]](namespace.std) [1](#namespace.std-1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2991) Unless otherwise specified, the behavior of a C++ program is undefined if it adds declarations or definitions to namespacestd or to a namespace within namespacestd[.](#namespace.std-1.sentence-1) [2](#namespace.std-2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2998) Unless explicitly prohibited, a program may add a template specialization for any standard library class template to namespacestd provided that - [(2.1)](#namespace.std-2.1) the added declaration depends on at least one program-defined type, and - [(2.2)](#namespace.std-2.2) the specialization meets the standard library requirements for the original template[.](#namespace.std-2.sentence-1)[151](#footnote-151 "Any library code that instantiates other library templates must be prepared to work adequately with any user-supplied specialization that meets the minimum requirements of this document.") [3](#namespace.std-3) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L3018) 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[.](#namespace.std-3.sentence-1) [*Note [1](#namespace.std-note-1)*: The requirements on an explicit or partial specialization are stated by each variable template that grants such permission[.](#namespace.std-3.sentence-2) — *end note*] [4](#namespace.std-4) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L3028) The behavior of a C++ program is undefined if it declares - [(4.1)](#namespace.std-4.1) an explicit specialization of any member function of a standard library class template, or - [(4.2)](#namespace.std-4.2) an explicit specialization of any member function template of a standard library class or class template, or - [(4.3)](#namespace.std-4.3) an explicit or partial specialization of any member class template of a standard library class or class template, or - [(4.4)](#namespace.std-4.4) a deduction guide for any standard library class template[.](#namespace.std-4.sentence-1) [5](#namespace.std-5) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L3043) A program may explicitly instantiate a class template defined in the standard library only if the declaration - [(5.1)](#namespace.std-5.1) depends on the name of at least one program-defined type, and - [(5.2)](#namespace.std-5.2) the instantiation meets the standard library requirements for the original template[.](#namespace.std-5.sentence-1) [6](#namespace.std-6) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L3054) Let *F* denote a standard library function ([[global.functions]](global.functions "16.4.6.4 Non-member functions")), a standard library static member function, or an instantiation of a standard library function template[.](#namespace.std-6.sentence-1) Unless *F* is designated an [*addressable function*](#def:function,addressable "16.4.5.2.1 Namespace std [namespace.std]"), the behavior of a C++ program is unspecified (possibly ill-formed) if it explicitly or implicitly attempts to form a pointer to *F*[.](#namespace.std-6.sentence-2) [*Note [2](#namespace.std-note-2)*: Possible means of forming such pointers include application of the unary & operator ([[expr.unary.op]](expr.unary.op "7.6.2.2 Unary operators")),addressof ([[specialized.addressof]](specialized.addressof "20.2.11 addressof")), or a function-to-pointer standard conversion ([[conv.func]](conv.func "7.3.4 Function-to-pointer conversion"))[.](#namespace.std-6.sentence-3) — *end note*] 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]](member.functions "16.4.6.5 Member functions")) or an instantiation of a standard library member function template[.](#namespace.std-6.sentence-4) [7](#namespace.std-7) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L3082) Let *F* denote a standard library function or function template[.](#namespace.std-7.sentence-1) Unless *F* is designated an addressable function, it is unspecified if or how a reflection value designating the associated entity can be formed[.](#namespace.std-7.sentence-2) [*Note [3](#namespace.std-note-3)*: For example, it is possible that std​::​meta​::​members_of will not return reflections of standard library functions that an implementation handles through an extra-linguistic mechanism[.](#namespace.std-7.sentence-3) — *end note*] [8](#namespace.std-8) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L3095) Let *C* denote a standard library class or class template specialization[.](#namespace.std-8.sentence-1) 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[.](#namespace.std-8.sentence-2) [9](#namespace.std-9) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L3102) A translation unit shall not declare namespace std to be an inline namespace ([[namespace.def]](namespace.def "9.9.2 Namespace definition"))[.](#namespace.std-9.sentence-1) [151)](#footnote-151)[151)](#footnoteref-151) Any library code that instantiates other library templates must be prepared to work adequately with any user-supplied specialization that meets the minimum requirements of this document[.](#footnote-151.sentence-1) #### [16.4.5.2.2](#namespace.posix) Namespace posix [[namespace.posix]](namespace.posix) [1](#namespace.posix-1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L3107) The behavior of a C++ program is undefined if it adds declarations or definitions to namespaceposix or to a namespace within namespaceposix unless otherwise specified[.](#namespace.posix-1.sentence-1) The namespace posix is reserved for use by ISO/IEC/IEEE 9945 and other POSIX standards[.](#namespace.posix-1.sentence-2) #### [16.4.5.2.3](#namespace.future) Namespaces for future standardization [[namespace.future]](namespace.future) [1](#namespace.future-1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L3117) Top-level namespaces whose [*namespace-name*](namespace.def.general#nt:namespace-name "9.9.2.1 General [namespace.def.general]") consists of std followed by one or more [*digit*](lex.name#nt:digit "5.11 Identifiers [lex.name]")*s* ([[lex.name]](lex.name "5.11 Identifiers")) are reserved for future standardization[.](#namespace.future-1.sentence-1) The behavior of a C++ program is undefined if it adds declarations or definitions to such a namespace[.](#namespace.future-1.sentence-2) [*Example [1](#namespace.future-example-1)*: The top-level namespace std2 is reserved for use by future revisions of this International Standard[.](#namespace.future-1.sentence-3) — *end example*]