Skip to content

Commit 616d60c

Browse files
committed
[std] Introduce qualified-name and refactor grammar
1 parent af39c81 commit 616d60c

File tree

4 files changed

+121
-90
lines changed

4 files changed

+121
-90
lines changed

source/basic.tex

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2065,6 +2065,24 @@
20652065

20662066
\rSec3[basic.lookup.qual.general]{General}
20672067

2068+
\indextext{operator!scope resolution}%
2069+
\indextext{name hiding}%
2070+
%
2071+
\begin{bnf}
2072+
\nontermdef{nested-name-specifier}\br
2073+
\terminal{::}\br
2074+
type-name \terminal{::}\br
2075+
namespace-name \terminal{::}\br
2076+
decltype-specifier \terminal{::}\br
2077+
nested-name-specifier identifier \terminal{::}\br
2078+
nested-name-specifier \opt{\keyword{template}} simple-template-id \terminal{::}
2079+
\end{bnf}
2080+
\begin{bnf}
2081+
\nontermdef{qualified-name}\br
2082+
nested-name-specifier identifier\br
2083+
nested-name-specifier \opt{\keyword{template}} simple-template-id
2084+
\end{bnf}
2085+
20682086
\pnum
20692087
\indextext{lookup!qualified name|(}%
20702088
\indextext{name!qualified}%
@@ -2099,6 +2117,71 @@
20992117
\end{codeblock}
21002118
\end{example}
21012119

2120+
\pnum
2121+
\indextext{component name}%
2122+
The component names of a \grammarterm{nested-name-specifier} are
2123+
its \grammarterm{identifier} (if any) and those of its
2124+
\grammarterm{type-name},
2125+
\grammarterm{namespace-name},
2126+
\grammarterm{simple-template-id}, and/or
2127+
\grammarterm{nested-name-specifier}.
2128+
The component names of a \grammarterm{qualified-name} are
2129+
the \grammarterm{identifier} (if any) and those of its
2130+
\grammarterm{nested-name-specifier} and/or
2131+
\grammarterm{simple-template-id}.
2132+
2133+
\pnum
2134+
A \grammarterm{nested-name-specifier} is \defn{declarative} if it is part of
2135+
\begin{itemize}
2136+
\item
2137+
a \grammarterm{class-head-name},
2138+
\item
2139+
an \grammarterm{enum-head-name},
2140+
\item
2141+
a \grammarterm{qualified-id}
2142+
that is the \grammarterm{id-expression} of a \grammarterm{declarator-id}, or
2143+
\item
2144+
a declarative \grammarterm{nested-name-specifier}.
2145+
\end{itemize}
2146+
A declarative \grammarterm{nested-name-specifier}
2147+
shall not have a \grammarterm{decltype-specifier}.
2148+
A declaration that uses a declarative \grammarterm{nested-name-specifier}
2149+
shall be a friend declaration or
2150+
inhabit a scope that contains the entity being redeclared or specialized.
2151+
2152+
\pnum
2153+
The \grammarterm{nested-name-specifier} \tcode{::} nominates
2154+
the global namespace.
2155+
A \grammarterm{nested-name-specifier} with a \grammarterm{decltype-specifier}
2156+
nominates the type denoted by the \grammarterm{decltype-specifier},
2157+
which shall be a class or enumeration type.
2158+
If a \grammarterm{nested-name-specifier} $N$
2159+
is declarative and
2160+
has a \grammarterm{simple-template-id} with a template argument list $A$
2161+
that involves a template parameter,
2162+
let $T$ be the template nominated by $N$ without $A$.
2163+
$T$ shall be a class template.
2164+
\begin{itemize}
2165+
\item
2166+
If $A$ is the template argument list\iref{temp.arg} of
2167+
the corresponding \grammarterm{template-head} $H$\iref{temp.mem},
2168+
$N$ nominates the primary template of $T$;
2169+
$H$ shall be equivalent to
2170+
the \grammarterm{template-head} of $T$\iref{temp.over.link}.
2171+
\item
2172+
Otherwise, $N$ nominates the partial specialization\iref{temp.spec.partial} of $T$
2173+
whose template argument list is equivalent to $A$\iref{temp.over.link};
2174+
the program is ill-formed if no such partial specialization exists.
2175+
\end{itemize}
2176+
Any other \grammarterm{nested-name-specifier} nominates
2177+
the entity denoted by its
2178+
\grammarterm{type-name},
2179+
\grammarterm{namespace-name},
2180+
\grammarterm{identifier}, or
2181+
\grammarterm{simple-template-id}.
2182+
If the \grammarterm{nested-name-specifier} is not declarative,
2183+
the entity shall not be a template.
2184+
21022185
\indextext{operator!scope resolution}%
21032186
\indextext{scope resolution operator|see{operator, scope resolution}}%
21042187

@@ -2120,6 +2203,7 @@
21202203
\begin{itemize}
21212204
\item a \grammarterm{qualified-id},
21222205
\item a \grammarterm{simple-type-specifier},
2206+
\item a \grammarterm{qualified-name},
21232207
\item a \grammarterm{using-declarator},
21242208
\item a \grammarterm{typename-specifier},
21252209
\item a \grammarterm{qualified-namespace-specifier}, or

source/declarations.tex

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1275,8 +1275,9 @@
12751275
The simple type specifiers are
12761276
\begin{bnf}
12771277
\nontermdef{simple-type-specifier}\br
1278-
\opt{nested-name-specifier} type-name\br
1279-
nested-name-specifier \keyword{template} simple-template-id\br
1278+
qualified-name\br
1279+
nested-name-specifier simple-type-name\br
1280+
type-name\br
12801281
decltype-specifier\br
12811282
placeholder-type-specifier\br
12821283
\opt{nested-name-specifier} template-name\br
@@ -1297,9 +1298,14 @@
12971298
\end{bnf}
12981299

12991300
\begin{bnf}
1300-
\nontermdef{type-name}\br
1301+
\nontermdef{simple-type-name}\br
13011302
class-name\br
1302-
enum-name\br
1303+
enum-name
1304+
\end{bnf}
1305+
1306+
\begin{bnf}
1307+
\nontermdef{type-name}\br
1308+
simple-type-name\br
13031309
typedef-name
13041310
\end{bnf}
13051311

source/expressions.tex

Lines changed: 18 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1389,14 +1389,19 @@
13891389
\rSec3[expr.prim.id.unqual]{Unqualified names}
13901390

13911391
\begin{bnf}
1392-
\nontermdef{unqualified-id}\br
1393-
identifier\br
1392+
\nontermdef{unqualified-function-name}\br
13941393
operator-function-id\br
13951394
conversion-function-id\br
13961395
literal-operator-id\br
1396+
operator-template-id\br
13971397
\terminal{\~} type-name\br
13981398
\terminal{\~} decltype-specifier\br
1399-
template-id
1399+
\end{bnf}
1400+
\begin{bnf}
1401+
\nontermdef{unqualified-id}\br
1402+
identifier\br
1403+
simple-template-id\br
1404+
unqualified-function-name\br
14001405
\end{bnf}
14011406

14021407
\pnum
@@ -1426,8 +1431,10 @@
14261431
\item
14271432
$U$ if it is a name or
14281433
\item
1429-
the component name of
1430-
the \grammarterm{template-id} or \grammarterm{type-name} of $U$, if any.
1434+
the component name of the
1435+
\grammarterm{simple-template-id},
1436+
\grammarterm{operator-template-id}, or
1437+
\grammarterm{type-name} of $U$, if any.
14311438
\end{itemize}
14321439
\begin{note}
14331440
Other constructs that contain names to look up can have several component names
@@ -1493,84 +1500,16 @@
14931500
%
14941501
\begin{bnf}
14951502
\nontermdef{qualified-id}\br
1496-
nested-name-specifier \opt{\keyword{template}} unqualified-id
1497-
\end{bnf}
1498-
1499-
\indextext{operator!scope resolution}%
1500-
\indextext{name hiding}%
1501-
%
1502-
\begin{bnf}
1503-
\nontermdef{nested-name-specifier}\br
1504-
\terminal{::}\br
1505-
type-name \terminal{::}\br
1506-
namespace-name \terminal{::}\br
1507-
decltype-specifier \terminal{::}\br
1508-
nested-name-specifier identifier \terminal{::}\br
1509-
nested-name-specifier \opt{\keyword{template}} simple-template-id \terminal{::}
1503+
qualified-name\br
1504+
nested-name-specifier \opt{\keyword{template}} unqualified-function-name
15101505
\end{bnf}
15111506

15121507
\pnum
15131508
\indextext{component name}%
1514-
The component names of a \grammarterm{qualified-id} are those of
1515-
its \grammarterm{nested-name-specifier} and \grammarterm{unqualified-id}.
1516-
The component names of a \grammarterm{nested-name-specifier} are
1517-
its \grammarterm{identifier} (if any) and those of its
1518-
\grammarterm{type-name},
1519-
\grammarterm{namespace-name},
1520-
\grammarterm{simple-template-id}, and/or
1521-
\grammarterm{nested-name-specifier}.
1522-
1523-
\pnum
1524-
A \grammarterm{nested-name-specifier} is \defn{declarative} if it is part of
1525-
\begin{itemize}
1526-
\item
1527-
a \grammarterm{class-head-name},
1528-
\item
1529-
an \grammarterm{enum-head-name},
1530-
\item
1531-
a \grammarterm{qualified-id}
1532-
that is the \grammarterm{id-expression} of a \grammarterm{declarator-id}, or
1533-
\item
1534-
a declarative \grammarterm{nested-name-specifier}.
1535-
\end{itemize}
1536-
A declarative \grammarterm{nested-name-specifier}
1537-
shall not have a \grammarterm{decltype-specifier}.
1538-
A declaration that uses a declarative \grammarterm{nested-name-specifier}
1539-
shall be a friend declaration or
1540-
inhabit a scope that contains the entity being redeclared or specialized.
1541-
1542-
\pnum
1543-
The \grammarterm{nested-name-specifier} \tcode{::} nominates
1544-
the global namespace.
1545-
A \grammarterm{nested-name-specifier} with a \grammarterm{decltype-specifier}
1546-
nominates the type denoted by the \grammarterm{decltype-specifier},
1547-
which shall be a class or enumeration type.
1548-
If a \grammarterm{nested-name-specifier} $N$
1549-
is declarative and
1550-
has a \grammarterm{simple-template-id} with a template argument list $A$
1551-
that involves a template parameter,
1552-
let $T$ be the template nominated by $N$ without $A$.
1553-
$T$ shall be a class template.
1554-
\begin{itemize}
1555-
\item
1556-
If $A$ is the template argument list\iref{temp.arg} of
1557-
the corresponding \grammarterm{template-head} $H$\iref{temp.mem},
1558-
$N$ nominates the primary template of $T$;
1559-
$H$ shall be equivalent to
1560-
the \grammarterm{template-head} of $T$\iref{temp.over.link}.
1561-
\item
1562-
Otherwise, $N$ nominates the partial specialization\iref{temp.spec.partial} of $T$
1563-
whose template argument list is equivalent to $A$\iref{temp.over.link};
1564-
the program is ill-formed if no such partial specialization exists.
1565-
\end{itemize}
1566-
Any other \grammarterm{nested-name-specifier} nominates
1567-
the entity denoted by its
1568-
\grammarterm{type-name},
1569-
\grammarterm{namespace-name},
1570-
\grammarterm{identifier}, or
1571-
\grammarterm{simple-template-id}.
1572-
If the \grammarterm{nested-name-specifier} is not declarative,
1573-
the entity shall not be a template.
1509+
The component names of a \grammarterm{qualified-id} are those of its
1510+
\grammarterm{qualified-name},
1511+
\grammarterm{nested-name-specifier}, and/or
1512+
\grammarterm{unqualified-function-name}.
15741513

15751514
\pnum
15761515
A \grammarterm{qualified-id} shall not be of the form

source/templates.tex

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -663,11 +663,16 @@
663663
template-name \terminal{<} \opt{template-argument-list} \terminal{>}
664664
\end{bnf}
665665

666+
\begin{bnf}
667+
\nontermdef{operator-template-id}\br
668+
operator-function-id \terminal{<} \opt{template-argument-list} \terminal{>}\br
669+
literal-operator-id \terminal{<} \opt{template-argument-list} \terminal{>}
670+
\end{bnf}
671+
666672
\begin{bnf}
667673
\nontermdef{template-id}\br
668674
simple-template-id\br
669-
operator-function-id \terminal{<} \opt{template-argument-list} \terminal{>}\br
670-
literal-operator-id \terminal{<} \opt{template-argument-list} \terminal{>}
675+
operator-template-id
671676
\end{bnf}
672677

673678
\begin{bnf}
@@ -692,6 +697,7 @@
692697
\indextext{component name}%
693698
The component name of a
694699
\grammarterm{simple-template-id},
700+
\grammarterm{operator-template-id},
695701
\grammarterm{template-id}, or
696702
\grammarterm{template-name}
697703
is the first name in it.
@@ -4385,11 +4391,7 @@
43854391
\end{example}
43864392

43874393
\pnum
4388-
Each of the forms
4389-
\begin{ncsimplebnf}
4390-
nested-name-specifier identifier\br
4391-
nested-name-specifier \opt{\keyword{template}} simple-template-id
4392-
\end{ncsimplebnf}
4394+
A \grammarterm{qualified-name}
43934395
where the terminal name $N$ is dependent\iref{temp.dep.type}
43944396
is interpreted as a \grammarterm{simple-type-specifier}\iref{dcl.type.simple}
43954397
if $N$ is in a type-only context and

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy