From 91b5ed4664a93dcc983f95705d2d562c5e112afd Mon Sep 17 00:00:00 2001 From: Vlad Serebrennikov Date: Tue, 8 Oct 2024 15:30:13 +0400 Subject: [PATCH] [temp.pre] Fix note about uniqueness of a template name in a scope --- source/templates.tex | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/source/templates.tex b/source/templates.tex index 34db14f83a..9d7fb3e1fa 100644 --- a/source/templates.tex +++ b/source/templates.tex @@ -143,12 +143,26 @@ \begin{note} A template cannot have the same name as any other name bound in the same scope\iref{basic.scope.scope}, except -that a function template can share a name with non-template -functions\iref{dcl.fct} and/or function templates\iref{temp.over}. +that a function template can share a name with \grammarterm{using-declarator}s, +a type, non-template functions\iref{dcl.fct} and/or function templates\iref{temp.over}. Specializations, including partial specializations\iref{temp.spec.partial}, do not reintroduce or bind names. Their target scope is the target scope of the primary template, so all specializations of a template belong to the same scope as it does. +\begin{example} +\begin{codeblock} +void f() {} +class f {}; // OK +namespace N { + void f(int) {} +} +using N::f; // OK +template void f(long) {} // \#1, OK +template void f(long) {} // error: redefinition of \#1 +template void f(long long) {} // OK +template<> void f(long long) {} // OK, doesn't bind a name +\end{codeblock} +\end{example} \end{note} \pnum