C++ Logo

STD-DISCUSSION

Advanced search

Subject: Re: Extending a namespace in an inline namespace that initially was defined in the enclosing namespace of the inline namespace
From: Brian Bi (bbi5291_at_[hidden])
Date: 2019-10-24 17:53:47


On Wed, Oct 23, 2019 at 1:11 PM Vladimir Grigoriev via Std-Discussion <
std-discussion_at_[hidden]> wrote:

> In the section Section 9.7.1 Namespace definition: if the C++ 20 Standard
> there is written
>
> 2 In a named-namespace-definition, the identifier is the name of the
> namespace. If the identifier, when looked up (6.4.1), refers to a
> namespace-name (but not a namespace-alias) that was introduced in the
> namespace in which the named-namespace-definition appears or that was
> introduced in a member of the inline namespace set of that namespace, the
> namespace-definition extends the previously-declared namespace. Otherwise,
> the identifier is introduced as a namespace-name into the declarative
> region in which the named-namespace definition appears.
>
> This program is compiled successfully.
>
> #include <iostream>
>
> inline namespace N1
> {
> inline namespace N2
> {
> namespace N3
> {
> void f( int ) { std::cout << "f( int )\n"; }
> }
> }
>
> namespace N3
> {
> void f( char ) { std::cout << "f( char )\n"; }
> }
> }
>
> int main()
> {
> N3::f( 10 );
> N2::N3::f( 'A' );
> }
>
> Is it a reasonable intention of the Standard that such a program would be
> well-formed?
>
It seems to me that if this had not been intentionally allowed, then the
author of this paragraph would not have written "or... in a member of the
inline namespace set".

> With best regards
> (Vlad from Moscow)
>
> You can meet me at http://cpp.forum24.ru/ or www.stackoverflow.com or
> http://ru.stackoverflow.com
> --
> Std-Discussion mailing list
> Std-Discussion_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-discussion
>

-- 
*Brian Bi*


STD-DISCUSSION list run by herb.sutter at gmail.com

Older Archives on Google Groups