Skip to content

Commit aeb1e95

Browse files
committedOct 8, 2024·
[temp.pre] Fix note about uniqueness of a template name in a scope
1 parent aa62b37 commit aeb1e95

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed
 

‎source/templates.tex

+16-2
Original file line numberDiff line numberDiff line change
@@ -143,12 +143,26 @@
143143
\begin{note}
144144
A template cannot have the same name as any other
145145
name bound in the same scope\iref{basic.scope.scope}, except
146-
that a function template can share a name with non-template
147-
functions\iref{dcl.fct} and/or function templates\iref{temp.over}.
146+
that a function template can share a name with \grammarterm{using-declarator}s,
147+
a type, non-template functions\iref{dcl.fct} and/or function templates\iref{temp.over}.
148148
Specializations, including partial specializations\iref{temp.spec.partial},
149149
do not reintroduce or bind names.
150150
Their target scope is the target scope of the primary template,
151151
so all specializations of a template belong to the same scope as it does.
152+
\begin{example}
153+
\begin{codeblock}
154+
void f() {}
155+
class f {}; // OK
156+
namespace N {
157+
void f(int) {}
158+
}
159+
using N::f; // OK
160+
template<typename> void f(long) {} // #1, OK
161+
template<typename> void f(long) {} // error: redefinition of #1
162+
template<typename> void f(long long) {} // OK
163+
template<> void f<int>(long long) {} // OK, doesn't bind a name
164+
\end{codeblock}
165+
\end{example}
152166
\end{note}
153167

154168
\pnum

0 commit comments

Comments
 (0)