<!DOCTYPE html><html lang='en'><head><title>[namespace.std]</title><meta charset='UTF-8'/><link rel='stylesheet' type='text/css' href='14882.css'/><link rel='stylesheet' type='text/css' href='expanded.css' title='Notes and examples expanded'/><link rel='alternate stylesheet' type='text/css' href='colored.css' title='Notes and examples colored'/><link rel='alternate stylesheet' type='text/css' href='collapsed.css' title='Notes and examples collapsed'/><link rel='icon' href='icon.png'/></head><body><div class='wrapper'><h1 ><a class='secnum' style='min-width:73pt'>15</a> Library introduction <a class='abbr_ref' href='./#library'>[library]</a></h1><h2 ><a class='secnum' style='min-width:88pt'>15.5</a> Library-wide requirements <a class='abbr_ref' href='requirements#namespace.std'>[requirements]</a></h2><h3 ><a class='secnum' style='min-width:103pt'>15.5.4</a> Constraints on programs <a class='abbr_ref' href='constraints#namespace.std'>[constraints]</a></h3><h4 ><a class='secnum' style='min-width:118pt'>15.5.4.2</a> Namespace use <a class='abbr_ref' href='namespace.constraints#namespace.std'>[namespace.constraints]</a></h4><h4 ><a class='secnum' style='min-width:133pt'>15.5.4.2.1</a> Namespace <span class='texttt'>std</span> <a class='abbr_ref'>[namespace.std]</a></h4><div class='para' id='1'><div class='marginalizedparent'><a class='marginalized' href='#1'>1</a></div><div class='sourceLinkParent'><a class='sourceLink' href='https://github.com/Eelis/draft73ca144c7e48612fe72742f9f6a5ec9ad6a934d2/source/lib-intro.tex#L2371'>#</a></div><div id='1.sentence-1' class='sentence'>Unless otherwise specified,
the behavior of a C++ program is undefined if it adds declarations or definitions to namespace
<span class='texttt'>std</span>
or to a namespace within namespace
<span class='texttt'>std</span><a class='hidden_link' href='#1.sentence-1'>.</a></div></div><div class='para' id='2'><div class='marginalizedparent'><a class='marginalized' href='#2'>2</a></div><div class='sourceLinkParent'><a class='sourceLink' href='https://github.com/Eelis/draft73ca144c7e48612fe72742f9f6a5ec9ad6a934d2/source/lib-intro.tex#L2378'>#</a></div><div id='2.sentence-1' class='sentence'>Unless explicitly prohibited,
a program may add a template specialization for
any standard library class template
to namespace
<span class='texttt'>std</span> provided that
(a) the added declaration
depends on at least one program-defined type
and
(b) the specialization meets the standard library requirements
for the original template<a class='hidden_link' href='#2.sentence-1'>.</a><a class='footnotenum' href='#footnote-174'>174</a></div></div><div class='para' id='3'><div class='marginalizedparent'><a class='marginalized' href='#3'>3</a></div><div class='sourceLinkParent'><a class='sourceLink' href='https://github.com/Eelis/draft73ca144c7e48612fe72742f9f6a5ec9ad6a934d2/source/lib-intro.tex#L2393'>#</a></div><div id='3.sentence-1' class='sentence'>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<a class='hidden_link' href='#3.sentence-1'>.</a></div></div><div class='para' id='4'><div class='marginalizedparent'><a class='marginalized' href='#4'>4</a></div><div class='sourceLinkParent'><a class='sourceLink' href='https://github.com/Eelis/draft73ca144c7e48612fe72742f9f6a5ec9ad6a934d2/source/lib-intro.tex#L2399'>#</a></div><div id='4.sentence-1' class='sentence'>The behavior of a C++ program is undefined if it declares
<ul class='itemize'><li id='4.1'><div class='marginalizedparent' style='left:-7em'><a class='marginalized' href='#4.1'>(4.1)</a></div><div id='4.1.sentence-1' class='sentence'>an explicit specialization of any member function of a standard
library class template, or</div></li><li id='4.2'><div class='marginalizedparent' style='left:-7em'><a class='marginalized' href='#4.2'>(4.2)</a></div><div id='4.2.sentence-1' class='sentence'>an explicit specialization of any member function template of a
standard library class or class template, or</div></li><li id='4.3'><div class='marginalizedparent' style='left:-7em'><a class='marginalized' href='#4.3'>(4.3)</a></div><div id='4.3.sentence-1' class='sentence'>an explicit or partial specialization of any member class template
of a standard library class or class template, or</div></li><li id='4.4'><div class='marginalizedparent' style='left:-7em'><a class='marginalized' href='#4.4'>(4.4)</a></div><div id='4.4.sentence-1' class='sentence'>a deduction guide for any standard library class template<a class='hidden_link' href='#4.4.sentence-1'>.</a></div></li></ul></div></div><div class='para' id='5'><div class='marginalizedparent'><a class='marginalized' href='#5'>5</a></div><div class='sourceLinkParent'><a class='sourceLink' href='https://github.com/Eelis/draft73ca144c7e48612fe72742f9f6a5ec9ad6a934d2/source/lib-intro.tex#L2414'>#</a></div><div id='5.sentence-1' class='sentence'>A program may explicitly instantiate
a class template defined in the standard library
only if the declaration
(a) depends on the name of at least one program-defined type
and
(b) the instantiation meets the standard library requirements for the
original template<a class='hidden_link' href='#5.sentence-1'>.</a></div></div><div class='para' id='6'><div class='marginalizedparent'><a class='marginalized' href='#6'>6</a></div><div class='sourceLinkParent'><a class='sourceLink' href='https://github.com/Eelis/draft73ca144c7e48612fe72742f9f6a5ec9ad6a934d2/source/lib-intro.tex#L2423'>#</a></div><div id='6.sentence-1' class='sentence'>Let <span class='texttt'><span class='textit'>F</span></span> denote
a standard library function (<a href='global.functions'>[global.functions]</a>),
a standard library static member function,
or an instantiation
of a standard library function template<a class='hidden_link' href='#6.sentence-1'>.</a></div> <div id='6.sentence-2' class='sentence'>Unless <span class='texttt'><span class='textit'>F</span></span> is designated
an <a class='hidden_link' href='#def:addressable_function' id='def:addressable_function'><i >addressable function</i></a>,
the behavior of a C++ program is unspecified (possibly ill-formed)
if it explicitly or implicitly attempts
to form a pointer
to <span class='texttt'><span class='textit'>F</span></span><a class='hidden_link' href='#6.sentence-2'>.</a></div> <div id='6.note-1' class='note'>[<span style='white-space:nowrap'> </span><a class='note_link' href='#6.note-1'><span class='textit'>Note</span></a><div class='noteBody'><span class='textit'>:</span> <div id='6.sentence-3' class='sentence'>Possible means of forming such pointers include
application of the unary <span class='texttt'><span class='operator'>&amp;</span></span> operator (<a href='expr.unary.op'>[expr.unary.op]</a>),
<span class='texttt'>addressof</span> (<a href='specialized.addressof'>[specialized.addressof]</a>),
or
a function-to-pointer standard conversion (<a href='conv.func'>[conv.func]</a>)<a class='hidden_link' href='#6.sentence-3'>.</a></div> —<span style='white-space:nowrap'> </span><i>end note</i></div><span style='white-space:nowrap'> </span>]</div>  <div id='6.sentence-4' class='sentence'>
Moreover,
the behavior of a C++ program is unspecified (possibly ill-formed)
if it attempts to form a reference
to <span class='texttt'><span class='textit'>F</span></span>
or
if it attempts to form a pointer-to-member designating
either a standard library non-static member function (<a href='member.functions'>[member.functions]</a>)
or an instantiation of a standard library member function template<a class='hidden_link' href='#6.sentence-4'>.</a></div></div><div class='para' id='7'><div class='marginalizedparent'><a class='marginalized' href='#7'>7</a></div><div class='sourceLinkParent'><a class='sourceLink' href='https://github.com/Eelis/draft73ca144c7e48612fe72742f9f6a5ec9ad6a934d2/source/lib-intro.tex#L2451'>#</a></div><div id='7.sentence-1' class='sentence'>Other than in namespace <span class='texttt'>std</span>
or in a namespace
within namespace <span class='texttt'>std</span>,
a program may provide
an overload for any library function template
designated as a <a class='hidden_link' href='#def:customization_point' id='def:customization_point'><i >customization point</i></a>,
provided that
(a)
the overload's declaration depends
on at least one user-defined type
and
(b)
the overload meets the standard library requirements
for the customization point<a class='hidden_link' href='#7.sentence-1'>.</a><a class='footnotenum' href='#footnote-175'>175</a></div> <div id='7.note-1' class='note'>[<span style='white-space:nowrap'> </span><a class='note_link' href='#7.note-1'><span class='textit'>Note</span></a><div class='noteBody'><span class='textit'>:</span> <div id='7.sentence-2' class='sentence'>This permits
a (qualified or unqualified) call
to the customization point
to invoke the most appropriate overload
for the given arguments<a class='hidden_link' href='#7.sentence-2'>.</a></div> —<span style='white-space:nowrap'> </span><i>end note</i></div><span style='white-space:nowrap'> </span>]</div> </div><div class='para' id='8'><div class='marginalizedparent'><a class='marginalized' href='#8'>8</a></div><div class='sourceLinkParent'><a class='sourceLink' href='https://github.com/Eelis/draft73ca144c7e48612fe72742f9f6a5ec9ad6a934d2/source/lib-intro.tex#L2497'>#</a></div><div id='8.sentence-1' class='sentence'>A translation unit shall not declare namespace <span class='texttt'>std</span> to be an inline namespace (<a href='namespace.def'>[namespace.def]</a>)<a class='hidden_link' href='#8.sentence-1'>.</a></div></div><div class='footnote' id='footnote-174'><div class='footnoteNumberParent'><a class='marginalized' href='#footnote-174'>174)</a></div><div id='footnote-174.sentence-1' class='sentence'>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<a class='hidden_link' href='#footnote-174.sentence-1'>.</a></div></div><div class='footnote' id='footnote-175'><div class='footnoteNumberParent'><a class='marginalized' href='#footnote-175'>175)</a></div><div id='footnote-175.sentence-1' class='sentence'>Any library customization point
must be prepared
to work adequately
with any user-defined overload
that meets the minimum requirements
of this document<a class='hidden_link' href='#footnote-175.sentence-1'>.</a></div> <div id='footnote-175.sentence-2' class='sentence'>Therefore
an implementation may elect,
under the as-if rule (<a href='intro.execution'>[intro.execution]</a>),
to provide any customization point
in the form
of an instantiated function object (<a href='function.objects'>[function.objects]</a>)
even though the customization point's specification
is in the form
of a function template<a class='hidden_link' href='#footnote-175.sentence-2'>.</a></div> <div id='footnote-175.sentence-3' class='sentence'>The template parameters
of each such function object
and the function parameters
and return type
of the object's <span class='texttt'><span class='keyword'>operator</span><span class='parenthesis'>(</span><span class='parenthesis'>)</span></span>
must match those
of the corresponding customization point's specification<a class='hidden_link' href='#footnote-175.sentence-3'>.</a></div></div></div></body></html>