29.12.2014 Views

RealView Compilation Tools Compiler Reference Guide - ARM ...

RealView Compilation Tools Compiler Reference Guide - ARM ...

RealView Compilation Tools Compiler Reference Guide - ARM ...

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 />

namespace M {<br />

int x = 99;<br />

double g(double);<br />

N::A ai;<br />

int i = ai.f(0);<br />

int i2 = ai.f();<br />

N::A ad;<br />

double d = ad.f(0);<br />

double d2 = ad.f();<br />

}<br />

// N::A::f(int) calls N::g(int)<br />

// N::A::f() returns 0 (= N::x)<br />

// N::A::f(double) calls M::g(double)<br />

// N::A::f() also returns 0 (= N::x)<br />

The lookup of names in template instantiations does not conform to the rules in the<br />

standard in the following respects:<br />

• Although only names from the template definition context are considered for<br />

names that are not functions, the lookup is not limited to those names visible at<br />

the point where the template is defined.<br />

• Functions from the context where the template is referenced are considered for all<br />

function calls in the template. Functions from the referencing context are only<br />

visible for dependent function calls.<br />

Argument-dependent lookup<br />

When argument-dependent lookup is enabled, functions that are made visible using<br />

argument-dependent lookup can overload with those made visible by normal lookup.<br />

The standard requires that this overloading occur even when the name found by normal<br />

lookup is a block extern declaration. The compiler does this overloading, but in default<br />

mode, argument-dependent lookup is suppressed when the normal lookup finds a block<br />

extern.<br />

This means a program can have different behavior, depending on whether it is compiled<br />

with or without argument-dependent lookup, even if the program makes no use of<br />

namespaces. For example:<br />

struct A { };<br />

A operator+(A, double);<br />

void f()<br />

{<br />

A a1;<br />

A operator+(A, int);<br />

a1 + 1.0;<br />

// calls operator+(A, double) with arg-dependent lookup<br />

} // enabled but otherwise calls operator+(A, int);<br />

<strong>ARM</strong> DUI 0348A Copyright © 2007, 2010 <strong>ARM</strong> Limited. All rights reserved. 5-17<br />

Non-Confidential

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

Saved successfully!

Ooh no, something went wrong!