This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [Patch] Document pitfalls of two-stage name lookup, next revision
Gerald Pfeifer <pfeifer@dbai.tuwien.ac.at> writes:
| On Thu, 6 Feb 2003, Wolfgang Bangerth wrote:
| > This is with Mark's and Gaby's suggestions built in. There didn't seem
| > to be any more comments, so I think this can go in.
| >
| > Gerald, I promise not to route too many patches via you, but can you
| > take care of this one as well?
|
| Sure, though I'd feel more comfortable to get a final ACK by Gaby,
| Mark (or Jason).
Globally, it is OK modulo the comments below.
[...]
| +@node Name lookup
| +@subsection Name lookup, templates, and accessing members of base classes
| +
| +@cindex base class members
| +@cindex two-stage name lookup
| +@cindex dependent name lookup
| +
| +The C++ standard prescribes that all names that are not template
| +dependent are bound to their present definitions when parsing a template
| +function or class.@footnote{The C++ standard just uses the term
| +``dependent'' for names that depend on the type or value of template
| +arguments.
s/template arguments/template parameters/.
I really find the term "template dependent" very confusing because
there are three kinds of template parameters:
* type parameters, i.e. "T" in "template<typename T>"
* value parameters, i.e. "N" in "template<int N>"
* template parameters, i.e. TT in "template<template<typename> class TT"
Names that depend on value parameters are called "value dependent";
those that depend on type parameters are called "type dependent".
Guess how one should call names that depend on template
template-parameters :-)
Just ditch the footnote and use the standard terminology ("dependent
name") in the main course of the document.
[...]
| +@example
| + template <typename T> struct Base @{
| + int i;
| + @};
| +
| + template <typename T> struct Derived : public Base<T> @{
| + int get_i() @{ return i; @}
| + @};
| +@end example
| +
| +In @code{get_i()}, @code{i} is not used in a dependent context, so the
| +compiler will look for a global variable of that name.
Suggestion of alternative wordings:
[...] so the compiler will look for a name declared at the enclosing
namespace scope (which is the global scope here).
-- Gaby