04.01.2015 Views

RealView Compilation Tools - ARM Information Center

RealView Compilation Tools - ARM Information Center

RealView Compilation Tools - ARM Information Center

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

C and C++ Implementation Details<br />

See Command-line options on page 2-2 for more information.<br />

5.2.6 Namespaces<br />

When doing name lookup in a template instantiation, some names must be found in the<br />

context of the template definition. Other names can be found in the context of the<br />

template instantiation. The compiler implements two different instantiation lookup<br />

algorithms:<br />

• the algorithm mandated by the standard, and referred to as dependent name<br />

lookup.<br />

• the algorithm that exists before dependent name lookup is implemented.<br />

Dependent name lookup is done in strict mode, unless explicitly disabled by another<br />

command-line option, or when dependent name processing is enabled by either a<br />

configuration flag or a command-line option.<br />

Dependent name lookup processing<br />

When doing dependent name lookup, the compiler implements the instantiation name<br />

lookup rules specified in the standard. This processing requires that non class prototype<br />

instantiations be done. This in turn requires that the code be written using the typename<br />

and template keywords as required by the standard.<br />

Lookup using the referencing context<br />

When not using dependent name lookup, the compiler uses a name lookup algorithm<br />

that approximates the two-phase lookup rule of the standard, but in a way that is more<br />

compatible with existing code and existing compilers.<br />

When a name is looked up as part of a template instantiation, but is not found in the local<br />

context of the instantiation, it is looked up in a synthesized instantiation context. This<br />

synthesized instantiation context includes both names from the context of the template<br />

definition and names from the context of the instantiation. For example:<br />

namespace N<br />

{<br />

int g(int);<br />

int x = 0;<br />

template struct A<br />

{<br />

T f(T t) { return g(t); }<br />

T f() { return x; }<br />

};<br />

}<br />

5-16 Copyright © 2007-2010 <strong>ARM</strong>. All rights reserved. <strong>ARM</strong> DUI 0348C<br />

Non-Confidential,<br />

ID101213

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!