C++ Logo

STD-DISCUSSION

Advanced search

Subject: Re: Qualified name of an enumerator.
From: Brian Bi (bbi5291_at_[hidden])
Date: 2019-08-28 11:51:51


I wouldn't expect this to be allowed, as it violates
[basic.scope.declarative]/4
<http://eel.is/c++draft/basic.scope.declarative#4> and [namespace.udecl]/12
<http://eel.is/c++draft/namespace.udecl#12> by declaring N as two different
entities in the same declarative region, namely the namespace N and the
enumerator N::N in the global namespace.

On Wed, Aug 28, 2019 at 11:20 AM Vladimir Grigoriev via Std-Discussion <
std-discussion_at_[hidden]> wrote:

> May a name of an enumerator coincide with a name of a namespace in a using
> declaration.
>
> That is whether this using declaration
>
> using N::N;
>
>
> is valid or not and why.
>
> #include <iostream>
>
> namespace N
> {
> enum { N = 10 };
>
> void f()
> {
> std::cout << "N = " << N << '\n';
> }
> }
>
> using N::N;
>
> void f()
> {
> std::cout << "N = " << N << '\n';
> }
>
> int main()
> {
> N::f();
> f();
>
> return 0;
> }
>
>
>
> 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