Date: Thu, 24 Oct 2019 19:53:42 -0400
I see it as perfectly logical, given the ways inline namespaces work. Anything inside the inline namespace will "appear" to be visible in the enclosing namespace, so the wording for extending namespaces here is extended to model that behavior as well.
-------- Original message --------From: Brian Bi via Std-Discussion <std-discussion_at_[hidden]> Date: 10/24/19 18:53 (GMT-05:00) To: std-discussion_at_[hidden] Cc: Brian Bi <bbi5291_at_[hidden]> Subject: Re: [std-discussion] Extending a namespace in an inline namespace that initially was defined in the enclosing namespace of the inline namespace 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 written2 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
-------- Original message --------From: Brian Bi via Std-Discussion <std-discussion_at_[hidden]> Date: 10/24/19 18:53 (GMT-05:00) To: std-discussion_at_[hidden] Cc: Brian Bi <bbi5291_at_[hidden]> Subject: Re: [std-discussion] Extending a namespace in an inline namespace that initially was defined in the enclosing namespace of the inline namespace 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 written2 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
Received on 2019-10-24 18:56:00