Skip to content

Commit 7bf24f8

Browse files
Add DeclSort::Prolongation (#174)
Formalize out-of-home-scope declaration, i.e. declarations with _qualified-id_ as _declarator-id_.
1 parent a807f15 commit 7bf24f8

File tree

2 files changed

+121
-5
lines changed

2 files changed

+121
-5
lines changed

ltx/decls.tex

Lines changed: 118 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
\enumerator{Destructor}
3434
\enumerator{Reference}
3535
\enumerator{UsingDeclaration}
36-
\enumerator{Unused0}
36+
\enumerator{Prolongation}
3737
\enumerator{Friend}
3838
\enumerator{Expansion}
3939
\enumerator{DeductionGuide}
@@ -1221,11 +1221,124 @@ \subsection{\valueTag{DeclSort::UsingDeclaration}}
12211221
\note{This representation is subject to change. Future revision will represents this as the result of executing a \grammar{using-declaration} (\sortref{DeclUse}{DirSort}) directive.}
12221222

12231223

1224-
\subsection{\valueTag{DeclSort::Unused0}}
1225-
\label{sec:ifc:DeclSort:Unused0}
1224+
\subsection{\valueTag{DeclSort::Prolongation}}
1225+
\label{sec:ifc:DeclSort:Prolongation}
12261226

1227-
\diffNote{This tag was previously named \valueTag{DeclSort::UsingDirective} but had no defined structure and was never emitted.
1228-
For \grammar{using-directive}, see \sortref{Using}{DirSort}.}
1227+
A \type{DeclIndex} abstract reference with tag \valueTag{DeclSort::Prolongation} designates an out-of-home-scope
1228+
definition for an entity previously declared in its home scope. The \field{index} of that abstract reference
1229+
is an index into the prolongation declaration partition. Each entry in that partition is a structure with the
1230+
following layout
1231+
%
1232+
\begin{figure}[H]
1233+
\centering
1234+
\structure{
1235+
\DeclareMember{name}{NamedIndex} \\
1236+
\DeclareMember{locus}{SourceLocation} \\
1237+
\DeclareMember{enclosing\_scope}{DeclIndex} \\
1238+
\DeclareMember{home\_scope}{DeclIndex} \\
1239+
\DeclareMember{original\_decl}{DeclIndex} \\
1240+
}
1241+
\caption{Structure of a prolongation}
1242+
\label{fig:DeclSort:Prolongation}
1243+
\end{figure}
1244+
%
1245+
with the following semantics:
1246+
\begin{itemize}
1247+
\item The \field{name} field designates the \grammar{unqualified-id} name of the prolongation
1248+
\item The \field{locus} field designates the source location of the prolongation
1249+
\item The \field{enclosing\_scope} field is the \type{DeclIndex} for the lexical enclosing scope of the prolongation
1250+
\item The \field{home\_scope} field designates the home scope of the original declaration
1251+
\item The \field{original\_decl} field designates the original declaration being prolonged by this prolongation
1252+
\end{itemize}
1253+
1254+
\partition{decl.prolongation}
1255+
1256+
\subsubsection{Prolongations, by examples}
1257+
\label{ifc:DeclSort:Prolongation-by-examples}
1258+
1259+
Below are various examples of prolongations. The term \textit{proclamation} is used to
1260+
mean a parameterized prolongation.
1261+
1262+
\paragraph{Prolongation of a class template}
1263+
A member declared in a class template can be defined outside out the enclosing class scope definition.
1264+
For instance, in
1265+
\begin{lstlisting}
1266+
template<typename S>
1267+
struct X {
1268+
void f(); // #6
1269+
};
1270+
1271+
template<typename S>
1272+
void X<S>::f() { } // #7
1273+
\end{lstlisting}
1274+
1275+
the definition on line \#7 proclaims a prolongation of \code{X<S>} for \code{X<S>::f} given any
1276+
type \code{S}. That is called a prolongation proclamation, \ie{} a prescription of prolongations
1277+
for all instantiations of the class template \code{X} for a member code{f}.
1278+
1279+
\paragraph{Prolongation for a member template}
1280+
A member template of a class (that is not a template) defined outside of the enclosing class definition
1281+
yields a prolongation. For example, in
1282+
\begin{lstlisting}
1283+
struct A {
1284+
template<typename T> T f(T); // #8
1285+
};
1286+
1287+
template<typename T> // #9
1288+
T A::f(T t) { return t; }
1289+
\end{lstlisting}
1290+
1291+
the definition at line \#9 is a prolongation of the class \code{A} for the member template \code{f}
1292+
delcared at line \#8.
1293+
1294+
When a member template of a class template is defined outside of the enclosing class template definition, the
1295+
out-of-class template definition is a prolongation of that class template for that member template.
1296+
For example, the program fragments
1297+
\begin{lstlisting}
1298+
template<typename U>
1299+
struct X {
1300+
template<typename V> // #10
1301+
struct Y;
1302+
template<typename T> // #11
1303+
int cmp(Y<T>);
1304+
};
1305+
1306+
template<typename U> // #12
1307+
template<typename V>
1308+
struct X<U>::Y { };
1309+
1310+
template<typename S> // #13
1311+
template<typename T>
1312+
int X<S>::cmp(Y<T>) { return 1; }
1313+
\end{lstlisting}
1314+
1315+
contains the following parameterized prolongations (proclamations):
1316+
\begin{itemize}
1317+
\item the definition at line \#12 is a prolongation proclamation (with parameters \code{<typename U>})
1318+
of the class template \code{X} for the member class template \code{X<U>:Y}
1319+
\item the deifnition at line \#13 is a prolongation proclamation (with parameters \code{<typename S>})
1320+
of the class template \code{X} for the non-static member function template \code{X<S>::cmp}
1321+
\end{itemize}
1322+
1323+
\paragraph{Prolongation of an implicit instantiation}
1324+
A program can provide (through explicit specialization) a definition for a member of an implicit instantiation of a class template.
1325+
For example, in
1326+
\begin{lstlisting}
1327+
template<typename T>
1328+
struct Z {
1329+
T f(T t) { return t + 1; } // #14
1330+
};
1331+
1332+
// explicit specialization for Z<int>::f
1333+
template<> // #15
1334+
int Z<int>::f(int t) { return t * t; }
1335+
\end{lstlisting}
1336+
1337+
although the definition of the class \code{Z<int>} is generated from the primary template \code{Z},
1338+
the definition of the member function \code{Z<int>::f} is not generated is not implicitly generated
1339+
from that of \code{Z<int>::f} at line \#14. Rather, that definition is given by the explicit specialization
1340+
at line \#15. In short, the definition at line \#15 is a prolongation of \code{Z<int>} for the
1341+
non-defining declaration implicitly generated from the templated declaration at line \#14.
12291342

12301343
\subsection{\valueTag{DeclSort::Friend}}
12311344
\label{sec:ifc:DeclSort:Friend}

ltx/ifc-format.sty

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@
3838
colorlinks=true
3939
}
4040

41+
\newcommand{\ie}{\emph{i.e.}}
42+
\newcommand{\eg}{\emph{e.g.}}
43+
4144
%% Typesetting meta variables
4245
\newcommand{\var}[1]{\ensuremath{\mathtt{#1}}}
4346

0 commit comments

Comments
 (0)