C++2011: inline namespaces

Olivier JG olivier.jg at gmail.com
Tue Jul 5 23:19:14 UTC 2011


On 07/06/2011 03:19 AM, Milian Wolff wrote:
> Foremost it would help me if we could come up with a list of examples I can 
> use for writing unit tests...

GCC has some tests :
ftp://gd.tuwien.ac.at/gnu/gcc/releases/gcc-4.6.1/gcc-testsuite-4.6.1.tar.bz2

(look for: "gcc/testsuite/g++.dg/cpp0x/inline-ns*.C")

That should be pretty exhaustive.

> So far so good. But I'm not so sure about the implications - and where to 
> change what code. Furthermore the point about explicit qualification is unclear 
> to me.
This part "Finally, looking up a name in the enclosing namespace via
explicit qualification ([namespace.qual]) will include members of the
inline namespace brought in by the using directive even if there are
declarations of that name in the enclosing namespace." ...?

I take it to mean that it shouldn't give priority to the non-inlined
(ie, the enclosing) namespace when trying to resolve a usage naming
conflict. This doesn't mean that code that does something so silly will
be magically correct however, just basically that "the usual rules apply".

See also (in particular point 2):
http://www.slac.stanford.edu/BFROOT/www/Computing/Environment/Standards/C++/cd2/basic.html#namespace.qual

Quoting:
"Otherwise if the use of [namespace member 'm'] is not one that allows a
unique declaration to be chosen from [the declarations of m in the
namespace], the program is ill-formed."

Hope that helps,

-Olivier JG




More information about the KDevelop-devel mailing list