Skip to content

dependent names #4793

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 85 additions & 0 deletions source/basic.tex
Original file line number Diff line number Diff line change
Expand Up @@ -2065,6 +2065,24 @@

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

\indextext{operator!scope resolution}%
\indextext{name hiding}%
%
\begin{bnf}
\nontermdef{nested-name-specifier}\br
\terminal{::}\br
type-name \terminal{::}\br
namespace-name \terminal{::}\br
decltype-specifier \terminal{::}\br
nested-name-specifier identifier \terminal{::}\br
nested-name-specifier \opt{\keyword{template}} simple-template-id \terminal{::}
\end{bnf}
\begin{bnf}
\nontermdef{qualified-name}\br
nested-name-specifier identifier\br
nested-name-specifier \opt{\keyword{template}} simple-template-id
\end{bnf}

\pnum
\indextext{lookup!qualified name|(}%
\indextext{name!qualified}%
Expand Down Expand Up @@ -2099,6 +2117,71 @@
\end{codeblock}
\end{example}

\pnum
\indextext{component name}%
The component names of a \grammarterm{nested-name-specifier} are
its \grammarterm{identifier} (if any) and those of its
\grammarterm{type-name},
\grammarterm{namespace-name},
\grammarterm{simple-template-id}, and/or
\grammarterm{nested-name-specifier}.
The component names of a \grammarterm{qualified-name} are
the \grammarterm{identifier} (if any) and those of its
\grammarterm{nested-name-specifier} and/or
\grammarterm{simple-template-id}.

\pnum
A \grammarterm{nested-name-specifier} is \defn{declarative} if it is part of
\begin{itemize}
\item
a \grammarterm{class-head-name},
\item
an \grammarterm{enum-head-name},
\item
a \grammarterm{qualified-id}
that is the \grammarterm{id-expression} of a \grammarterm{declarator-id}, or
\item
a declarative \grammarterm{nested-name-specifier}.
\end{itemize}
A declarative \grammarterm{nested-name-specifier}
shall not have a \grammarterm{decltype-specifier}.
A declaration that uses a declarative \grammarterm{nested-name-specifier}
shall be a friend declaration or
inhabit a scope that contains the entity being redeclared or specialized.

\pnum
The \grammarterm{nested-name-specifier} \tcode{::} nominates
the global namespace.
A \grammarterm{nested-name-specifier} with a \grammarterm{decltype-specifier}
nominates the type denoted by the \grammarterm{decltype-specifier},
which shall be a class or enumeration type.
If a \grammarterm{nested-name-specifier} $N$
is declarative and
has a \grammarterm{simple-template-id} with a template argument list $A$
that involves a template parameter,
let $T$ be the template nominated by $N$ without $A$.
$T$ shall be a class template.
\begin{itemize}
\item
If $A$ is the template argument list\iref{temp.arg} of
the corresponding \grammarterm{template-head} $H$\iref{temp.mem},
$N$ nominates the primary template of $T$;
$H$ shall be equivalent to
the \grammarterm{template-head} of $T$\iref{temp.over.link}.
\item
Otherwise, $N$ nominates the partial specialization\iref{temp.spec.partial} of $T$
whose template argument list is equivalent to $A$\iref{temp.over.link};
the program is ill-formed if no such partial specialization exists.
\end{itemize}
Any other \grammarterm{nested-name-specifier} nominates
the entity denoted by its
\grammarterm{type-name},
\grammarterm{namespace-name},
\grammarterm{identifier}, or
\grammarterm{simple-template-id}.
If the \grammarterm{nested-name-specifier} is not declarative,
the entity shall not be a template.

\indextext{operator!scope resolution}%
\indextext{scope resolution operator|see{operator, scope resolution}}%

Expand All @@ -2119,6 +2202,8 @@
\item the terminal name of
\begin{itemize}
\item a \grammarterm{qualified-id},
\item a \grammarterm{simple-type-specifier},
\item a \grammarterm{qualified-name},
\item a \grammarterm{using-declarator},
\item a \grammarterm{typename-specifier},
\item a \grammarterm{qualified-namespace-specifier}, or
Expand Down
14 changes: 10 additions & 4 deletions source/declarations.tex
Original file line number Diff line number Diff line change
Expand Up @@ -1275,8 +1275,9 @@
The simple type specifiers are
\begin{bnf}
\nontermdef{simple-type-specifier}\br
\opt{nested-name-specifier} type-name\br
nested-name-specifier \keyword{template} simple-template-id\br
qualified-name\br
nested-name-specifier simple-type-name\br
type-name\br
decltype-specifier\br
placeholder-type-specifier\br
\opt{nested-name-specifier} template-name\br
Expand All @@ -1297,9 +1298,14 @@
\end{bnf}

\begin{bnf}
\nontermdef{type-name}\br
\nontermdef{simple-type-name}\br
class-name\br
enum-name\br
enum-name
\end{bnf}

\begin{bnf}
\nontermdef{type-name}\br
simple-type-name\br
typedef-name
\end{bnf}

Expand Down
97 changes: 18 additions & 79 deletions source/expressions.tex
Original file line number Diff line number Diff line change
Expand Up @@ -1389,14 +1389,19 @@
\rSec3[expr.prim.id.unqual]{Unqualified names}

\begin{bnf}
\nontermdef{unqualified-id}\br
identifier\br
\nontermdef{unqualified-function-name}\br
operator-function-id\br
conversion-function-id\br
literal-operator-id\br
operator-template-id\br
\terminal{\~} type-name\br
\terminal{\~} decltype-specifier\br
template-id
\end{bnf}
\begin{bnf}
\nontermdef{unqualified-id}\br
identifier\br
simple-template-id\br
unqualified-function-name\br
\end{bnf}

\pnum
Expand Down Expand Up @@ -1426,8 +1431,10 @@
\item
$U$ if it is a name or
\item
the component name of
the \grammarterm{template-id} or \grammarterm{type-name} of $U$, if any.
the component name of the
\grammarterm{simple-template-id},
\grammarterm{operator-template-id}, or
\grammarterm{type-name} of $U$, if any.
\end{itemize}
\begin{note}
Other constructs that contain names to look up can have several component names
Expand Down Expand Up @@ -1493,84 +1500,16 @@
%
\begin{bnf}
\nontermdef{qualified-id}\br
nested-name-specifier \opt{\keyword{template}} unqualified-id
\end{bnf}

\indextext{operator!scope resolution}%
\indextext{name hiding}%
%
\begin{bnf}
\nontermdef{nested-name-specifier}\br
\terminal{::}\br
type-name \terminal{::}\br
namespace-name \terminal{::}\br
decltype-specifier \terminal{::}\br
nested-name-specifier identifier \terminal{::}\br
nested-name-specifier \opt{\keyword{template}} simple-template-id \terminal{::}
qualified-name\br
nested-name-specifier \opt{\keyword{template}} unqualified-function-name
\end{bnf}

\pnum
\indextext{component name}%
The component names of a \grammarterm{qualified-id} are those of
its \grammarterm{nested-name-specifier} and \grammarterm{unqualified-id}.
The component names of a \grammarterm{nested-name-specifier} are
its \grammarterm{identifier} (if any) and those of its
\grammarterm{type-name},
\grammarterm{namespace-name},
\grammarterm{simple-template-id}, and/or
\grammarterm{nested-name-specifier}.

\pnum
A \grammarterm{nested-name-specifier} is \defn{declarative} if it is part of
\begin{itemize}
\item
a \grammarterm{class-head-name},
\item
an \grammarterm{enum-head-name},
\item
a \grammarterm{qualified-id}
that is the \grammarterm{id-expression} of a \grammarterm{declarator-id}, or
\item
a declarative \grammarterm{nested-name-specifier}.
\end{itemize}
A declarative \grammarterm{nested-name-specifier}
shall not have a \grammarterm{decltype-specifier}.
A declaration that uses a declarative \grammarterm{nested-name-specifier}
shall be a friend declaration or
inhabit a scope that contains the entity being redeclared or specialized.

\pnum
The \grammarterm{nested-name-specifier} \tcode{::} nominates
the global namespace.
A \grammarterm{nested-name-specifier} with a \grammarterm{decltype-specifier}
nominates the type denoted by the \grammarterm{decltype-specifier},
which shall be a class or enumeration type.
If a \grammarterm{nested-name-specifier} $N$
is declarative and
has a \grammarterm{simple-template-id} with a template argument list $A$
that involves a template parameter,
let $T$ be the template nominated by $N$ without $A$.
$T$ shall be a class template.
\begin{itemize}
\item
If $A$ is the template argument list\iref{temp.arg} of
the corresponding \grammarterm{template-head} $H$\iref{temp.mem},
$N$ nominates the primary template of $T$;
$H$ shall be equivalent to
the \grammarterm{template-head} of $T$\iref{temp.over.link}.
\item
Otherwise, $N$ nominates the partial specialization\iref{temp.spec.partial} of $T$
whose template argument list is equivalent to $A$\iref{temp.over.link};
the program is ill-formed if no such partial specialization exists.
\end{itemize}
Any other \grammarterm{nested-name-specifier} nominates
the entity denoted by its
\grammarterm{type-name},
\grammarterm{namespace-name},
\grammarterm{identifier}, or
\grammarterm{simple-template-id}.
If the \grammarterm{nested-name-specifier} is not declarative,
the entity shall not be a template.
The component names of a \grammarterm{qualified-id} are those of its
\grammarterm{qualified-name},
\grammarterm{nested-name-specifier}, and/or
\grammarterm{unqualified-function-name}.

\pnum
A \grammarterm{qualified-id} shall not be of the form
Expand Down
23 changes: 16 additions & 7 deletions source/templates.tex
Original file line number Diff line number Diff line change
Expand Up @@ -664,12 +664,17 @@
\end{bnf}

\begin{bnf}
\nontermdef{template-id}\br
simple-template-id\br
\nontermdef{operator-template-id}\br
operator-function-id \terminal{<} \opt{template-argument-list} \terminal{>}\br
literal-operator-id \terminal{<} \opt{template-argument-list} \terminal{>}
\end{bnf}

\begin{bnf}
\nontermdef{template-id}\br
simple-template-id\br
operator-template-id
\end{bnf}

\begin{bnf}
\nontermdef{template-name}\br
identifier
Expand All @@ -692,6 +697,7 @@
\indextext{component name}%
The component name of a
\grammarterm{simple-template-id},
\grammarterm{operator-template-id},
\grammarterm{template-id}, or
\grammarterm{template-name}
is the first name in it.
Expand Down Expand Up @@ -4385,13 +4391,16 @@
\end{example}

\pnum
A \grammarterm{qualified-id}
whose terminal name is dependent and that is in a type-only context
is considered to denote a type.
A \grammarterm{qualified-name}
where the terminal name $N$ is dependent\iref{temp.dep.type}
is interpreted as a \grammarterm{simple-type-specifier}\iref{dcl.type.simple}
if $N$ is in a type-only context and
as a \grammarterm{qualified-id}\iref{expr.prim.id.qual} otherwise.
A name
that refers to a \grammarterm{using-declarator} whose terminal name is dependent
is interpreted as a \grammarterm{typedef-name}
if the \grammarterm{using-declarator} uses the keyword \keyword{typename}.
is interpreted as a \grammarterm{typedef-name}\iref{dcl.typedef}
if the \grammarterm{using-declarator} uses the keyword \keyword{typename}
and as an \grammarterm{unqualified-id}\iref{expr.prim.id.unqual} otherwise.
\begin{example}
\begin{codeblock}
template <class T> void f(int i) {
Expand Down