|
33 | 33 | \enumerator{Destructor} |
34 | 34 | \enumerator{Reference} |
35 | 35 | \enumerator{UsingDeclaration} |
36 | | - \enumerator{Unused0} |
| 36 | + \enumerator{Prolongation} |
37 | 37 | \enumerator{Friend} |
38 | 38 | \enumerator{Expansion} |
39 | 39 | \enumerator{DeductionGuide} |
@@ -1221,11 +1221,124 @@ \subsection{\valueTag{DeclSort::UsingDeclaration}} |
1221 | 1221 | \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.} |
1222 | 1222 |
|
1223 | 1223 |
|
1224 | | -\subsection{\valueTag{DeclSort::Unused0}} |
1225 | | -\label{sec:ifc:DeclSort:Unused0} |
| 1224 | +\subsection{\valueTag{DeclSort::Prolongation}} |
| 1225 | +\label{sec:ifc:DeclSort:Prolongation} |
1226 | 1226 |
|
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. |
1229 | 1342 |
|
1230 | 1343 | \subsection{\valueTag{DeclSort::Friend}} |
1231 | 1344 | \label{sec:ifc:DeclSort:Friend} |
|
0 commit comments