1

If a namespace is defined inline, is neccesary to declare the extension namespaces inlineas well? In other words is it permitted to declare a namespace to be inline only once and omit the qualifier in extension declarations?

Andrey Pro
  • 501
  • 1
  • 10
  • 22
  • This is also asked [here](http://stackoverflow.com/questions/11016220/what-are-inline-namespaces-for), although not answered – M.M Mar 02 '17 at 23:08

1 Answers1

0

I've had an opportunity to ask the best adviser - compiler (g++ 4.9.2) :)

So what I found out:

It is not neccessary to qualify namespces to be inline in extension definitons. The type of the namespace seems to be fixed in the defining declaration (=the first one the compiler sees). The subsequent qualifications are simply ignored. Thus, if a someone tries to make the namespace inline in an extension defenition, the compiler won't give any special warning, rather it will simply complain about missing class/function declarations.

Still it depends on application whether to qualify the extension namespaces. In my case it is not necessary because there clear include hierarchy ensured by inheritance. If this not the case, it may be still good idea qualify the inline namespaces in the header files because it may be not known which declaration will be the defining one.

Andrey Pro
  • 501
  • 1
  • 10
  • 22
  • This is close to what the standard says, but not exact; see [\[namespace.def\]/5](http://eel.is/c++draft/namespace.def#5). – bogdan Mar 03 '17 at 16:53