Topic: Omitting namespace/class scopes for scoped enums


Author: Kenshi Takayama <kenshi84@gmail.com>
Date: Mon, 27 Oct 2014 16:04:50 -0700 (PDT)
Raw View
------=_Part_2719_1402886359.1414451090080
Content-Type: text/plain; charset=UTF-8

Hi,

I'm a big fan of the scoped enum feature introduced in C++11 since it
avoids unintended mixing of enums and integers.
However, I also find it redundant to have to type all its namespace/class
scopes every time I compare or substitute some enum constant to another
enum variable.
For example, I'd like the following code to work:

namespace A {
  namespace B {
    struct X {
      struct Y {
        enum struct E {
          e0,
          e1,
          e2,
        };
      };
    };
  }
}

void f() {
  A::B::X::Y::E var = e0;    // A::B::X::Y::E var = A::B::X::Y::E::e0;
  if (var == e1)             // if (var == A::B::X::Y::E::e1)
    var = e2;                //   var = A::B::X::Y::E::e2;
  switch (var) {
  case e0:                   // case A::B::X::Y::E::e0:
    break;
  }
}

Would it be reasonable to allow this code?

Thanks,
Kenshi

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

------=_Part_2719_1402886359.1414451090080
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Hi,<div><br></div><div>I'm a big fan of the scoped enum fe=
ature introduced in C++11 since it avoids unintended mixing of enums and in=
tegers.</div><div>However, I also find it redundant to have to type all its=
 namespace/class scopes every time I compare or substitute some enum consta=
nt to another enum variable.</div><div>For example, I'd like the following =
code to work:</div><div><br></div><div><div class=3D"prettyprint" style=3D"=
border: 1px solid rgb(187, 187, 187); word-wrap: break-word; background-col=
or: rgb(250, 250, 250);"><code class=3D"prettyprint"><div class=3D"subprett=
yprint"><span style=3D"color: #008;" class=3D"styled-by-prettify">namespace=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> A </span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">{</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; </span><span st=
yle=3D"color: #008;" class=3D"styled-by-prettify">namespace</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"> B </span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">{</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; </span><span style=3D"co=
lor: #008;" class=3D"styled-by-prettify">struct</span><span style=3D"color:=
 #000;" class=3D"styled-by-prettify"> X </span><span style=3D"color: #660;"=
 class=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"><br>&nbsp; &nbsp; &nbsp; </span><span style=3D"color: =
#008;" class=3D"styled-by-prettify">struct</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> Y </span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style=3D"color=
: #008;" class=3D"styled-by-prettify">enum</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">struct</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> E </span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">{</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; e0</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; e1</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; &nbsp; &n=
bsp; &nbsp; e2</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&=
nbsp; &nbsp; &nbsp; &nbsp; </span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">};</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"><br>&nbsp; &nbsp; &nbsp; </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">};</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"><br>&nbsp; &nbsp; </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">};</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"><br>&nbsp; </span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">}</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"><br></span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">}</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br=
></span><span style=3D"color: #008;" class=3D"styled-by-prettify">void</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> f</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">()</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">{</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"><br>&nbsp; A</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">::</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify">B</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">::</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y">X</span><span style=3D"color: #660;" class=3D"styled-by-prettify">::</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify">Y</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">::</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify">E </span><span style=3D"color: =
#008;" class=3D"styled-by-prettify">var</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">=3D</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"> e0</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> &n=
bsp; &nbsp;</span><span style=3D"color: #800;" class=3D"styled-by-prettify"=
>// A::B::X::Y::E var =3D A::B::X::Y::E::e0;</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"><br>&nbsp; </span><span style=3D"color: #=
008;" class=3D"styled-by-prettify">if</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> </span><font color=3D"#666600"><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #00=
8;" class=3D"styled-by-prettify">var</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">=3D=3D</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"> e1</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">)</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> &n=
bsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style=3D"color: #800;"=
 class=3D"styled-by-prettify">// if (var =3D=3D A::B::X::Y::E::e1)</span></=
font><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &=
nbsp; </span><span style=3D"color: #008;" class=3D"styled-by-prettify">var<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> e2</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; =
&nbsp; &nbsp;</span><span style=3D"color: #800;" class=3D"styled-by-prettif=
y">// &nbsp; var =3D A::B::X::Y::E::e2;</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"><br>&nbsp; </span><span style=3D"color: #008;"=
 class=3D"styled-by-prettify">switch</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">(</span><span style=3D"color: #008;" class=3D"styled-by-pr=
ettify">var</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>)</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">{</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; </span><span st=
yle=3D"color: #008;" class=3D"styled-by-prettify">case</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> e</span><font color=3D"#666600=
"><span style=3D"color: #000;" class=3D"styled-by-prettify">0</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">:</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> &nbsp; &nbsp; &nbsp; &nbsp; &nbs=
p; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style=3D"color: #800;" class=3D=
"styled-by-prettify">// case A::B::X::Y::E::e0:</span><span style=3D"color:=
 #000;" class=3D"styled-by-prettify"><br></span></font><span style=3D"color=
: #000;" class=3D"styled-by-prettify">&nbsp; &nbsp; </span><span style=3D"c=
olor: #008;" class=3D"styled-by-prettify">break</span><span style=3D"color:=
 #660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"><br>&nbsp; </span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">}</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"><br></span><span style=3D"color: rgb(102, 102, 0); font=
-family: Arial, Helvetica, sans-serif;"><span style=3D"color: #660;" class=
=3D"styled-by-prettify">}</span></span><span style=3D"color: rgb(136, 0, 0)=
; font-family: Arial, Helvetica, sans-serif;"><span style=3D"color: #000;" =
class=3D"styled-by-prettify"><br></span></span></div></code></div><br>Would=
 it be reasonable to allow this code?</div><div><br></div><div>Thanks,</div=
><div>Kenshi</div></div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_2719_1402886359.1414451090080--

.


Author: Jens Maurer <Jens.Maurer@gmx.net>
Date: Tue, 28 Oct 2014 07:17:49 +0100
Raw View
On 10/28/2014 12:04 AM, Kenshi Takayama wrote:
> Hi,
>
> I'm a big fan of the scoped enum feature introduced in C++11 since it avoids unintended mixing of enums and integers.
> However, I also find it redundant to have to type all its namespace/class scopes every time I compare or substitute some enum constant to another enum variable.
> For example, I'd like the following code to work:
>
> ||
> namespaceA {
>   namespaceB {
>     structX {
>       structY {
>         enumstructE {
>           e0,
>           e1,
>           e2,
>         };
>       };
>     };
>   }
> }
>
> voidf(){
>   A::B::X::Y::E var=e0;   // A::B::X::Y::E var = A::B::X::Y::E::e0;
>   if(var==e1)            // if (var == A::B::X::Y::E::e1)
>     var=e2;               //   var = A::B::X::Y::E::e2;
>   switch(var){
>   case e0:                  // case A::B::X::Y::E::e0:
>     break;
>   }
> }
>
> Would it be reasonable to allow this code?

That seems to be non-trivial, given that we somehow have to
change the lookup of the name "e1" after having seen "var"
in an unrelated subexpression.

What about

   e1 == var

for example?  Certainly, "==" should be symmetric.

Jens

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

.


Author: TONGARI J <tongari95@gmail.com>
Date: Tue, 28 Oct 2014 14:49:33 +0800
Raw View
--047d7bd904b2c26d3a0506760cd9
Content-Type: text/plain; charset=UTF-8

2014-10-28 7:04 GMT+08:00 Kenshi Takayama <kenshi84@gmail.com>:

> Hi,
>
> I'm a big fan of the scoped enum feature introduced in C++11 since it
> avoids unintended mixing of enums and integers.
> However, I also find it redundant to have to type all its namespace/class
> scopes every time I compare or substitute some enum constant to another
> enum variable.
> For example, I'd like the following code to work:
>
> namespace A {
>   namespace B {
>     struct X {
>       struct Y {
>         enum struct E {
>           e0,
>           e1,
>           e2,
>         };
>       };
>     };
>   }
> }
>
> void f() {
>   A::B::X::Y::E var = e0;    // A::B::X::Y::E var = A::B::X::Y::E::e0;
>   if (var == e1)             // if (var == A::B::X::Y::E::e1)
>     var = e2;                //   var = A::B::X::Y::E::e2;
>   switch (var) {
>   case e0:                   // case A::B::X::Y::E::e0:
>     break;
>   }
> }
>
> Would it be reasonable to allow this code?
>

+1 for `switch`, as for `==`, maybe it'd be better to allows us to access
the constant through variable, so we can write `var == var.e1`.

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

--047d7bd904b2c26d3a0506760cd9
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote">2014=
-10-28 7:04 GMT+08:00 Kenshi Takayama <span dir=3D"ltr">&lt;<a href=3D"mail=
to:kenshi84@gmail.com" target=3D"_blank">kenshi84@gmail.com</a>&gt;</span>:=
<br><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;bor=
der-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:sol=
id;padding-left:1ex"><div dir=3D"ltr">Hi,<div><br></div><div>I&#39;m a big =
fan of the scoped enum feature introduced in C++11 since it avoids unintend=
ed mixing of enums and integers.</div><div>However, I also find it redundan=
t to have to type all its namespace/class scopes every time I compare or su=
bstitute some enum constant to another enum variable.</div><div>For example=
, I&#39;d like the following code to work:</div><div><br></div><div><div st=
yle=3D"border:1px solid rgb(187,187,187);word-wrap:break-word;background-co=
lor:rgb(250,250,250)"><code><div><span style=3D"color:rgb(0,0,136)">namespa=
ce</span><span style=3D"color:rgb(0,0,0)"> A </span><span style=3D"color:rg=
b(102,102,0)">{</span><span style=3D"color:rgb(0,0,0)"><br>=C2=A0 </span><s=
pan style=3D"color:rgb(0,0,136)">namespace</span><span style=3D"color:rgb(0=
,0,0)"> B </span><span style=3D"color:rgb(102,102,0)">{</span><span style=
=3D"color:rgb(0,0,0)"><br>=C2=A0 =C2=A0 </span><span style=3D"color:rgb(0,0=
,136)">struct</span><span style=3D"color:rgb(0,0,0)"> X </span><span style=
=3D"color:rgb(102,102,0)">{</span><span style=3D"color:rgb(0,0,0)"><br>=C2=
=A0 =C2=A0 =C2=A0 </span><span style=3D"color:rgb(0,0,136)">struct</span><s=
pan style=3D"color:rgb(0,0,0)"> Y </span><span style=3D"color:rgb(102,102,0=
)">{</span><span style=3D"color:rgb(0,0,0)"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0=
 </span><span style=3D"color:rgb(0,0,136)">enum</span><span style=3D"color:=
rgb(0,0,0)"> </span><span style=3D"color:rgb(0,0,136)">struct</span><span s=
tyle=3D"color:rgb(0,0,0)"> E </span><span style=3D"color:rgb(102,102,0)">{<=
/span><span style=3D"color:rgb(0,0,0)"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 e0</span><span style=3D"color:rgb(102,102,0)">,</span><span style=3D"co=
lor:rgb(0,0,0)"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 e1</span><span style=
=3D"color:rgb(102,102,0)">,</span><span style=3D"color:rgb(0,0,0)"><br>=C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 e2</span><span style=3D"color:rgb(102,102,0=
)">,</span><span style=3D"color:rgb(0,0,0)"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0=
 </span><span style=3D"color:rgb(102,102,0)">};</span><span style=3D"color:=
rgb(0,0,0)"><br>=C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color:rgb(102,10=
2,0)">};</span><span style=3D"color:rgb(0,0,0)"><br>=C2=A0 =C2=A0 </span><s=
pan style=3D"color:rgb(102,102,0)">};</span><span style=3D"color:rgb(0,0,0)=
"><br>=C2=A0 </span><span style=3D"color:rgb(102,102,0)">}</span><span styl=
e=3D"color:rgb(0,0,0)"><br></span><span style=3D"color:rgb(102,102,0)">}</s=
pan><span style=3D"color:rgb(0,0,0)"><br><br></span><span style=3D"color:rg=
b(0,0,136)">void</span><span style=3D"color:rgb(0,0,0)"> f</span><span styl=
e=3D"color:rgb(102,102,0)">()</span><span style=3D"color:rgb(0,0,0)"> </spa=
n><span style=3D"color:rgb(102,102,0)">{</span><span style=3D"color:rgb(0,0=
,0)"><br>=C2=A0 A</span><span style=3D"color:rgb(102,102,0)">::</span><span=
 style=3D"color:rgb(0,0,0)">B</span><span style=3D"color:rgb(102,102,0)">::=
</span><span style=3D"color:rgb(0,0,0)">X</span><span style=3D"color:rgb(10=
2,102,0)">::</span><span style=3D"color:rgb(0,0,0)">Y</span><span style=3D"=
color:rgb(102,102,0)">::</span><span style=3D"color:rgb(0,0,0)">E </span><s=
pan style=3D"color:rgb(0,0,136)">var</span><span style=3D"color:rgb(0,0,0)"=
> </span><span style=3D"color:rgb(102,102,0)">=3D</span><span style=3D"colo=
r:rgb(0,0,0)"> e0</span><span style=3D"color:rgb(102,102,0)">;</span><span =
style=3D"color:rgb(0,0,0)"> =C2=A0 =C2=A0</span><span style=3D"color:rgb(13=
6,0,0)">// A::B::X::Y::E var =3D A::B::X::Y::E::e0;</span><span style=3D"co=
lor:rgb(0,0,0)"><br>=C2=A0 </span><span style=3D"color:rgb(0,0,136)">if</sp=
an><span style=3D"color:rgb(0,0,0)"> </span><font color=3D"#666600"><span s=
tyle=3D"color:rgb(102,102,0)">(</span><span style=3D"color:rgb(0,0,136)">va=
r</span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(1=
02,102,0)">=3D=3D</span><span style=3D"color:rgb(0,0,0)"> e1</span><span st=
yle=3D"color:rgb(102,102,0)">)</span><span style=3D"color:rgb(0,0,0)"> =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color:rgb(136,=
0,0)">// if (var =3D=3D A::B::X::Y::E::e1)</span></font><span style=3D"colo=
r:rgb(0,0,0)"><br>=C2=A0 =C2=A0 </span><span style=3D"color:rgb(0,0,136)">v=
ar</span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(=
102,102,0)">=3D</span><span style=3D"color:rgb(0,0,0)"> e2</span><span styl=
e=3D"color:rgb(102,102,0)">;</span><span style=3D"color:rgb(0,0,0)"> =C2=A0=
 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0</span><span style=3D"colo=
r:rgb(136,0,0)">// =C2=A0 var =3D A::B::X::Y::E::e2;</span><span style=3D"c=
olor:rgb(0,0,0)"><br>=C2=A0 </span><span style=3D"color:rgb(0,0,136)">switc=
h</span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(1=
02,102,0)">(</span><span style=3D"color:rgb(0,0,136)">var</span><span style=
=3D"color:rgb(102,102,0)">)</span><span style=3D"color:rgb(0,0,0)"> </span>=
<span style=3D"color:rgb(102,102,0)">{</span><span style=3D"color:rgb(0,0,0=
)"><br>=C2=A0 </span><span style=3D"color:rgb(0,0,136)">case</span><span st=
yle=3D"color:rgb(0,0,0)"> e</span><font color=3D"#666600"><span style=3D"co=
lor:rgb(0,0,0)">0</span><span style=3D"color:rgb(102,102,0)">:</span><span =
style=3D"color:rgb(0,0,0)"> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 </span><span style=3D"color:rgb(136,0,0)">// case A::B::X=
::Y::E::e0:</span><span style=3D"color:rgb(0,0,0)"><br></span></font><span =
style=3D"color:rgb(0,0,0)">=C2=A0 =C2=A0 </span><span style=3D"color:rgb(0,=
0,136)">break</span><span style=3D"color:rgb(102,102,0)">;</span><span styl=
e=3D"color:rgb(0,0,0)"><br>=C2=A0 </span><span style=3D"color:rgb(102,102,0=
)">}</span><span style=3D"color:rgb(0,0,0)"><br></span><span style=3D"color=
:rgb(102,102,0);font-family:Arial,Helvetica,sans-serif"><span style=3D"colo=
r:rgb(102,102,0)">}</span></span><span style=3D"color:rgb(136,0,0);font-fam=
ily:Arial,Helvetica,sans-serif"><span style=3D"color:rgb(0,0,0)"><br></span=
></span></div></code></div><br>Would it be reasonable to allow this code?</=
div></div></blockquote><div><br></div><div>+1 for `switch`, as for `=3D=3D`=
, maybe it&#39;d be better to allows us to access the=C2=A0constant=C2=A0th=
rough variable, so we can write `var =3D=3D var.e1`.</div></div></div></div=
>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

--047d7bd904b2c26d3a0506760cd9--

.


Author: Thibaut Lutz <thibaut.lutz@googlemail.com>
Date: Tue, 28 Oct 2014 10:23:10 +0000
Raw View
--001a11c3ea44e62cb80506790905
Content-Type: text/plain; charset=UTF-8

We already have a way to access it "through the variable" using *decltype*,
no? It is a bit more verbose than deducing the scope magically but I think
it provides the same guarantees in terms of type safety and portability.

namespace A {

  namespace B {

    struct X {

      struct Y {

        enum struct E {

          e0, e1, e2,

        };

      };

    };

  }

}


int main() {

  A::B::X::Y::E var = decltype(var)::e0;

  switch(var){

    using E = decltype(var);

    case E::e0: ;

    case E::e1: ;

  }

}


On Tue, Oct 28, 2014 at 6:49 AM, TONGARI J <tongari95@gmail.com> wrote:

> 2014-10-28 7:04 GMT+08:00 Kenshi Takayama <kenshi84@gmail.com>:
>
>> Hi,
>>
>> I'm a big fan of the scoped enum feature introduced in C++11 since it
>> avoids unintended mixing of enums and integers.
>> However, I also find it redundant to have to type all its namespace/class
>> scopes every time I compare or substitute some enum constant to another
>> enum variable.
>> For example, I'd like the following code to work:
>>
>> namespace A {
>>   namespace B {
>>     struct X {
>>       struct Y {
>>         enum struct E {
>>           e0,
>>           e1,
>>           e2,
>>         };
>>       };
>>     };
>>   }
>> }
>>
>> void f() {
>>   A::B::X::Y::E var = e0;    // A::B::X::Y::E var = A::B::X::Y::E::e0;
>>   if (var == e1)             // if (var == A::B::X::Y::E::e1)
>>     var = e2;                //   var = A::B::X::Y::E::e2;
>>   switch (var) {
>>   case e0:                   // case A::B::X::Y::E::e0:
>>     break;
>>   }
>> }
>>
>> Would it be reasonable to allow this code?
>>
>
> +1 for `switch`, as for `==`, maybe it'd be better to allows us to access
> the constant through variable, so we can write `var == var.e1`.
>
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "ISO C++ Standard - Future Proposals" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to std-proposals+unsubscribe@isocpp.org.
> To post to this group, send email to std-proposals@isocpp.org.
> Visit this group at
> http://groups.google.com/a/isocpp.org/group/std-proposals/.
>



--
Thibaut LUTZ

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

--001a11c3ea44e62cb80506790905
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">We already have a way to access it &quot;through the varia=
ble&quot; using <i>decltype</i>, no? It is a bit more verbose than deducing=
 the scope magically but I think it provides the same guarantees in terms o=
f type safety and portability.<div><br></div><div>
<pre style=3D"margin-top:0px;margin-bottom:0px"><span style=3D"color:rgb(12=
8,128,0)">namespace</span><span style=3D"color:rgb(192,192,192)"> </span><s=
pan style=3D"color:rgb(128,0,128)">A</span><span style=3D"color:rgb(192,192=
,192)"> </span><span style=3D"color:rgb(0,0,0)">{</span></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px"><span style=3D"color:rgb(19=
2,192,192)">  </span><span style=3D"color:rgb(128,128,0)">namespace</span><=
span style=3D"color:rgb(192,192,192)"> </span><span style=3D"color:rgb(128,=
0,128)">B</span><span style=3D"color:rgb(192,192,192)"> </span><span style=
=3D"color:rgb(0,0,0)">{</span></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px"><span style=3D"color:rgb(19=
2,192,192)">    </span><span style=3D"color:rgb(128,128,0)">struct</span><s=
pan style=3D"color:rgb(192,192,192)"> </span><span style=3D"color:rgb(128,0=
,128)">X</span><span style=3D"color:rgb(192,192,192)"> </span><span style=
=3D"color:rgb(0,0,0)">{</span></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px"><span style=3D"color:rgb(19=
2,192,192)">      </span><span style=3D"color:rgb(128,128,0)">struct</span>=
<span style=3D"color:rgb(192,192,192)"> </span><span style=3D"color:rgb(128=
,0,128)">Y</span><span style=3D"color:rgb(192,192,192)"> </span><span style=
=3D"color:rgb(0,0,0)">{</span></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px"><span style=3D"color:rgb(19=
2,192,192)">        </span><span style=3D"color:rgb(128,128,0)">enum</span>=
<span style=3D"color:rgb(192,192,192)"> </span><span style=3D"color:rgb(128=
,128,0)">struct</span><span style=3D"color:rgb(192,192,192)"> </span><span =
style=3D"color:rgb(128,0,128)">E</span><span style=3D"color:rgb(192,192,192=
)"> </span><span style=3D"color:rgb(0,0,0)">{</span></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px"><span style=3D"color:rgb(19=
2,192,192)">          </span><span style=3D"color:rgb(128,0,128)">e0</span>=
<span style=3D"color:rgb(0,0,0)">,</span><span style=3D"color:rgb(192,192,1=
92)"> </span><span style=3D"color:rgb(128,0,128)">e1</span><span style=3D"c=
olor:rgb(0,0,0)">,</span><span style=3D"color:rgb(192,192,192)"> </span><sp=
an style=3D"color:rgb(128,0,128)">e2</span><span style=3D"color:rgb(0,0,0)"=
>,</span></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px"><span style=3D"color:rgb(19=
2,192,192)">        </span><span style=3D"color:rgb(0,0,0)">};</span></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px"><span style=3D"color:rgb(19=
2,192,192)">      </span><span style=3D"color:rgb(0,0,0)">};</span></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px"><span style=3D"color:rgb(19=
2,192,192)">    </span><span style=3D"color:rgb(0,0,0)">};</span></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px"><span style=3D"color:rgb(19=
2,192,192)">  </span><span style=3D"color:rgb(0,0,0)">}</span></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px"><span style=3D"color:rgb(0,=
0,0)">}</span></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px"><br></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px"><span style=3D"color:rgb(12=
8,128,0)">int</span><span style=3D"color:rgb(192,192,192)"> </span><span st=
yle=3D"color:rgb(0,0,0)">main</span><span style=3D"color:rgb(0,0,0)">()</sp=
an><span style=3D"color:rgb(192,192,192)"> </span><span style=3D"color:rgb(=
0,0,0)">{</span></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px"><span style=3D"color:rgb(19=
2,192,192)">  </span><span style=3D"color:rgb(128,0,128)">A</span><span sty=
le=3D"color:rgb(0,0,0)">::</span><span style=3D"color:rgb(128,0,128)">B</sp=
an><span style=3D"color:rgb(0,0,0)">::</span><span style=3D"color:rgb(128,0=
,128)">X</span><span style=3D"color:rgb(0,0,0)">::</span><span style=3D"col=
or:rgb(128,0,128)">Y</span><span style=3D"color:rgb(0,0,0)">::</span><span =
style=3D"color:rgb(128,0,128)">E</span><span style=3D"color:rgb(192,192,192=
)"> </span>var<span style=3D"color:rgb(192,192,192)"> </span><span style=3D=
"color:rgb(0,0,0)">=3D</span><span style=3D"color:rgb(192,192,192)"> </span=
><span style=3D"color:rgb(128,128,0)">decltype</span><span style=3D"color:r=
gb(0,0,0)">(</span>var<span style=3D"color:rgb(0,0,0)">)::</span>e0<span st=
yle=3D"color:rgb(0,0,0)">;</span></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px"><span style=3D"color:rgb(19=
2,192,192)">  </span><span style=3D"color:rgb(128,128,0)">switch</span><spa=
n style=3D"color:rgb(0,0,0)">(</span>var<span style=3D"color:rgb(0,0,0)">){=
</span></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px"><span style=3D"color:rgb(19=
2,192,192)">    </span><span style=3D"color:rgb(128,128,0)">using</span><sp=
an style=3D"color:rgb(192,192,192)"> </span><span style=3D"color:rgb(128,0,=
128)">E</span><span style=3D"color:rgb(192,192,192)"> </span><span style=3D=
"color:rgb(0,0,0)">=3D</span><span style=3D"color:rgb(192,192,192)"> </span=
><span style=3D"color:rgb(128,128,0)">decltype</span><span style=3D"color:r=
gb(0,0,0)">(</span>var<span style=3D"color:rgb(0,0,0)">);</span></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px"><span style=3D"color:rgb(19=
2,192,192)">    </span><span style=3D"color:rgb(128,128,0)">case</span><spa=
n style=3D"color:rgb(192,192,192)"> </span><span style=3D"color:rgb(128,0,1=
28)">E</span><span style=3D"color:rgb(0,0,0)">::</span>e0<span style=3D"col=
or:rgb(0,0,0)">:</span><span style=3D"color:rgb(192,192,192)"> </span><span=
 style=3D"color:rgb(0,0,0)">;</span></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px"><span style=3D"color:rgb(19=
2,192,192)">    </span><span style=3D"color:rgb(128,128,0)">case</span><spa=
n style=3D"color:rgb(192,192,192)"> </span><span style=3D"color:rgb(128,0,1=
28)">E</span><span style=3D"color:rgb(0,0,0)">::</span>e1<span style=3D"col=
or:rgb(0,0,0)">:</span><span style=3D"color:rgb(192,192,192)"> </span><span=
 style=3D"color:rgb(0,0,0)">;</span></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px"><span style=3D"color:rgb(19=
2,192,192)">  </span><span style=3D"color:rgb(0,0,0)">}</span></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px"><span style=3D"color:rgb(0,=
0,0)">}</span></pre></div></div><div class=3D"gmail_extra"><br><div class=
=3D"gmail_quote">On Tue, Oct 28, 2014 at 6:49 AM, TONGARI J <span dir=3D"lt=
r">&lt;<a href=3D"mailto:tongari95@gmail.com" target=3D"_blank">tongari95@g=
mail.com</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" style=
=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=
=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote"><span class=
=3D"">2014-10-28 7:04 GMT+08:00 Kenshi Takayama <span dir=3D"ltr">&lt;<a hr=
ef=3D"mailto:kenshi84@gmail.com" target=3D"_blank">kenshi84@gmail.com</a>&g=
t;</span>:<br><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px=
 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left=
-style:solid;padding-left:1ex"><div dir=3D"ltr">Hi,<div><br></div><div>I&#3=
9;m a big fan of the scoped enum feature introduced in C++11 since it avoid=
s unintended mixing of enums and integers.</div><div>However, I also find i=
t redundant to have to type all its namespace/class scopes every time I com=
pare or substitute some enum constant to another enum variable.</div><div>F=
or example, I&#39;d like the following code to work:</div><div><br></div><d=
iv><div style=3D"border:1px solid rgb(187,187,187);word-wrap:break-word;bac=
kground-color:rgb(250,250,250)"><code><div><span style=3D"color:rgb(0,0,136=
)">namespace</span><span style=3D"color:rgb(0,0,0)"> A </span><span style=
=3D"color:rgb(102,102,0)">{</span><span style=3D"color:rgb(0,0,0)"><br>=C2=
=A0 </span><span style=3D"color:rgb(0,0,136)">namespace</span><span style=
=3D"color:rgb(0,0,0)"> B </span><span style=3D"color:rgb(102,102,0)">{</spa=
n><span style=3D"color:rgb(0,0,0)"><br>=C2=A0 =C2=A0 </span><span style=3D"=
color:rgb(0,0,136)">struct</span><span style=3D"color:rgb(0,0,0)"> X </span=
><span style=3D"color:rgb(102,102,0)">{</span><span style=3D"color:rgb(0,0,=
0)"><br>=C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color:rgb(0,0,136)">stru=
ct</span><span style=3D"color:rgb(0,0,0)"> Y </span><span style=3D"color:rg=
b(102,102,0)">{</span><span style=3D"color:rgb(0,0,0)"><br>=C2=A0 =C2=A0 =
=C2=A0 =C2=A0 </span><span style=3D"color:rgb(0,0,136)">enum</span><span st=
yle=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(0,0,136)">struct<=
/span><span style=3D"color:rgb(0,0,0)"> E </span><span style=3D"color:rgb(1=
02,102,0)">{</span><span style=3D"color:rgb(0,0,0)"><br>=C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 e0</span><span style=3D"color:rgb(102,102,0)">,</span><sp=
an style=3D"color:rgb(0,0,0)"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 e1</sp=
an><span style=3D"color:rgb(102,102,0)">,</span><span style=3D"color:rgb(0,=
0,0)"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 e2</span><span style=3D"color:=
rgb(102,102,0)">,</span><span style=3D"color:rgb(0,0,0)"><br>=C2=A0 =C2=A0 =
=C2=A0 =C2=A0 </span><span style=3D"color:rgb(102,102,0)">};</span><span st=
yle=3D"color:rgb(0,0,0)"><br>=C2=A0 =C2=A0 =C2=A0 </span><span style=3D"col=
or:rgb(102,102,0)">};</span><span style=3D"color:rgb(0,0,0)"><br>=C2=A0 =C2=
=A0 </span><span style=3D"color:rgb(102,102,0)">};</span><span style=3D"col=
or:rgb(0,0,0)"><br>=C2=A0 </span><span style=3D"color:rgb(102,102,0)">}</sp=
an><span style=3D"color:rgb(0,0,0)"><br></span><span style=3D"color:rgb(102=
,102,0)">}</span><span style=3D"color:rgb(0,0,0)"><br><br></span><span styl=
e=3D"color:rgb(0,0,136)">void</span><span style=3D"color:rgb(0,0,0)"> f</sp=
an><span style=3D"color:rgb(102,102,0)">()</span><span style=3D"color:rgb(0=
,0,0)"> </span><span style=3D"color:rgb(102,102,0)">{</span><span style=3D"=
color:rgb(0,0,0)"><br>=C2=A0 A</span><span style=3D"color:rgb(102,102,0)">:=
:</span><span style=3D"color:rgb(0,0,0)">B</span><span style=3D"color:rgb(1=
02,102,0)">::</span><span style=3D"color:rgb(0,0,0)">X</span><span style=3D=
"color:rgb(102,102,0)">::</span><span style=3D"color:rgb(0,0,0)">Y</span><s=
pan style=3D"color:rgb(102,102,0)">::</span><span style=3D"color:rgb(0,0,0)=
">E </span><span style=3D"color:rgb(0,0,136)">var</span><span style=3D"colo=
r:rgb(0,0,0)"> </span><span style=3D"color:rgb(102,102,0)">=3D</span><span =
style=3D"color:rgb(0,0,0)"> e0</span><span style=3D"color:rgb(102,102,0)">;=
</span><span style=3D"color:rgb(0,0,0)"> =C2=A0 =C2=A0</span><span style=3D=
"color:rgb(136,0,0)">// A::B::X::Y::E var =3D A::B::X::Y::E::e0;</span><spa=
n style=3D"color:rgb(0,0,0)"><br>=C2=A0 </span><span style=3D"color:rgb(0,0=
,136)">if</span><span style=3D"color:rgb(0,0,0)"> </span><font color=3D"#66=
6600"><span style=3D"color:rgb(102,102,0)">(</span><span style=3D"color:rgb=
(0,0,136)">var</span><span style=3D"color:rgb(0,0,0)"> </span><span style=
=3D"color:rgb(102,102,0)">=3D=3D</span><span style=3D"color:rgb(0,0,0)"> e1=
</span><span style=3D"color:rgb(102,102,0)">)</span><span style=3D"color:rg=
b(0,0,0)"> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"=
color:rgb(136,0,0)">// if (var =3D=3D A::B::X::Y::E::e1)</span></font><span=
 style=3D"color:rgb(0,0,0)"><br>=C2=A0 =C2=A0 </span><span style=3D"color:r=
gb(0,0,136)">var</span><span style=3D"color:rgb(0,0,0)"> </span><span style=
=3D"color:rgb(102,102,0)">=3D</span><span style=3D"color:rgb(0,0,0)"> e2</s=
pan><span style=3D"color:rgb(102,102,0)">;</span><span style=3D"color:rgb(0=
,0,0)"> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0</span><span=
 style=3D"color:rgb(136,0,0)">// =C2=A0 var =3D A::B::X::Y::E::e2;</span><s=
pan style=3D"color:rgb(0,0,0)"><br>=C2=A0 </span><span style=3D"color:rgb(0=
,0,136)">switch</span><span style=3D"color:rgb(0,0,0)"> </span><span style=
=3D"color:rgb(102,102,0)">(</span><span style=3D"color:rgb(0,0,136)">var</s=
pan><span style=3D"color:rgb(102,102,0)">)</span><span style=3D"color:rgb(0=
,0,0)"> </span><span style=3D"color:rgb(102,102,0)">{</span><span style=3D"=
color:rgb(0,0,0)"><br>=C2=A0 </span><span style=3D"color:rgb(0,0,136)">case=
</span><span style=3D"color:rgb(0,0,0)"> e</span><font color=3D"#666600"><s=
pan style=3D"color:rgb(0,0,0)">0</span><span style=3D"color:rgb(102,102,0)"=
>:</span><span style=3D"color:rgb(0,0,0)"> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color:rgb(136,0,0)">/=
/ case A::B::X::Y::E::e0:</span><span style=3D"color:rgb(0,0,0)"><br></span=
></font><span style=3D"color:rgb(0,0,0)">=C2=A0 =C2=A0 </span><span style=
=3D"color:rgb(0,0,136)">break</span><span style=3D"color:rgb(102,102,0)">;<=
/span><span style=3D"color:rgb(0,0,0)"><br>=C2=A0 </span><span style=3D"col=
or:rgb(102,102,0)">}</span><span style=3D"color:rgb(0,0,0)"><br></span><spa=
n style=3D"color:rgb(102,102,0);font-family:Arial,Helvetica,sans-serif"><sp=
an style=3D"color:rgb(102,102,0)">}</span></span><span style=3D"color:rgb(1=
36,0,0);font-family:Arial,Helvetica,sans-serif"><span style=3D"color:rgb(0,=
0,0)"><br></span></span></div></code></div><br>Would it be reasonable to al=
low this code?</div></div></blockquote><div><br></div></span><div>+1 for `s=
witch`, as for `=3D=3D`, maybe it&#39;d be better to allows us to access th=
e=C2=A0constant=C2=A0through variable, so we can write `var =3D=3D var.e1`.=
</div></div></div></div><div class=3D"HOEnZb"><div class=3D"h5">

<p></p>

-- <br>
<br>
--- <br>
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org" target=3D"_=
blank">std-proposals+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
</div></div></blockquote></div><br><br clear=3D"all"><div><br></div>-- <br>=
Thibaut LUTZ
</div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

--001a11c3ea44e62cb80506790905--

.


Author: germinolegrand <germinolegrand@gmail.com>
Date: Tue, 28 Oct 2014 14:26:39 +0100
Raw View
This is a multi-part message in MIME format.
--------------080609090005010600050202
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: quoted-printable

Le 28/10/2014 07:49, TONGARI J a =C3=A9crit :
> 2014-10-28 7:04 GMT+08:00 Kenshi Takayama <kenshi84@gmail.com=20
> <mailto:kenshi84@gmail.com>>:
>
>     Hi,
>
>     I'm a big fan of the scoped enum feature introduced in C++11 since
>     it avoids unintended mixing of enums and integers.
>     However, I also find it redundant to have to type all its
>     namespace/class scopes every time I compare or substitute some
>     enum constant to another enum variable.
>     For example, I'd like the following code to work:
>
>     |
>     namespaceA {
>     namespaceB {
>     structX {
>     structY {
>     enumstructE {
>               e0,
>               e1,
>               e2,
>     };
>     };
>     };
>     }
>     }
>
>     voidf(){
>       A::B::X::Y::E var=3De0;// A::B::X::Y::E var =3D A::B::X::Y::E::e0;
>     if(var=3D=3De1)// if (var =3D=3D A::B::X::Y::E::e1)
>     var=3De2;//   var =3D A::B::X::Y::E::e2;
>     switch(var){
>     casee0:// case A::B::X::Y::E::e0:
>     break;
>     }
>     }
>     |
>
>     Would it be reasonable to allow this code?
>
>
> +1 for `switch`, as for `=3D=3D`, maybe it'd be better to allows us to=20
> access the constant through variable, so we can write `var =3D=3D var.e1`=
..
Currently, i believe we can do :
`var =3D=3D decltype(var)::e1`

--=20

---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.

--------------080609090005010600050202
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<html>
  <head>
    <meta content=3D"text/html; charset=3Dutf-8" http-equiv=3D"Content-Type=
">
  </head>
  <body bgcolor=3D"#FFFFFF" text=3D"#000000">
    <div class=3D"moz-cite-prefix">Le 28/10/2014 07:49, TONGARI J a
      =C3=A9crit=C2=A0:<br>
    </div>
    <blockquote
cite=3D"mid:CANCwVhcUQwhqUfu5Q=3DYLDFMHrP0mPwwpq2aaRCsjJQpdzaaHGg@mail.gmai=
l.com"
      type=3D"cite">
      <div dir=3D"ltr">
        <div class=3D"gmail_extra">
          <div class=3D"gmail_quote">2014-10-28 7:04 GMT+08:00 Kenshi
            Takayama <span dir=3D"ltr">&lt;<a moz-do-not-send=3D"true"
                href=3D"mailto:kenshi84@gmail.com" target=3D"_blank">kenshi=
84@gmail.com</a>&gt;</span>:<br>
            <blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-=
style:solid;padding-left:1ex">
              <div dir=3D"ltr">Hi,
                <div><br>
                </div>
                <div>I'm a big fan of the scoped enum feature introduced
                  in C++11 since it avoids unintended mixing of enums
                  and integers.</div>
                <div>However, I also find it redundant to have to type
                  all its namespace/class scopes every time I compare or
                  substitute some enum constant to another enum
                  variable.</div>
                <div>For example, I'd like the following code to work:</div=
>
                <div><br>
                </div>
                <div>
                  <div style=3D"border:1px solid
                    rgb(187,187,187);word-wrap:break-word;background-color:=
rgb(250,250,250)"><code>
                      <div><span style=3D"color:rgb(0,0,136)">namespace</sp=
an><span
                          style=3D"color:rgb(0,0,0)"> A </span><span
                          style=3D"color:rgb(102,102,0)">{</span><span
                          style=3D"color:rgb(0,0,0)"><br>
                          =C2=A0 </span><span style=3D"color:rgb(0,0,136)">=
namespace</span><span
                          style=3D"color:rgb(0,0,0)"> B </span><span
                          style=3D"color:rgb(102,102,0)">{</span><span
                          style=3D"color:rgb(0,0,0)"><br>
                          =C2=A0 =C2=A0 </span><span style=3D"color:rgb(0,0=
,136)">struct</span><span
                          style=3D"color:rgb(0,0,0)"> X </span><span
                          style=3D"color:rgb(102,102,0)">{</span><span
                          style=3D"color:rgb(0,0,0)"><br>
                          =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color:=
rgb(0,0,136)">struct</span><span
                          style=3D"color:rgb(0,0,0)"> Y </span><span
                          style=3D"color:rgb(102,102,0)">{</span><span
                          style=3D"color:rgb(0,0,0)"><br>
                          =C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span
                          style=3D"color:rgb(0,0,136)">enum</span><span
                          style=3D"color:rgb(0,0,0)"> </span><span
                          style=3D"color:rgb(0,0,136)">struct</span><span
                          style=3D"color:rgb(0,0,0)"> E </span><span
                          style=3D"color:rgb(102,102,0)">{</span><span
                          style=3D"color:rgb(0,0,0)"><br>
                          =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 e0</span><span
                          style=3D"color:rgb(102,102,0)">,</span><span
                          style=3D"color:rgb(0,0,0)"><br>
                          =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 e1</span><span
                          style=3D"color:rgb(102,102,0)">,</span><span
                          style=3D"color:rgb(0,0,0)"><br>
                          =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 e2</span><span
                          style=3D"color:rgb(102,102,0)">,</span><span
                          style=3D"color:rgb(0,0,0)"><br>
                          =C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span
                          style=3D"color:rgb(102,102,0)">};</span><span
                          style=3D"color:rgb(0,0,0)"><br>
                          =C2=A0 =C2=A0 =C2=A0 </span><span
                          style=3D"color:rgb(102,102,0)">};</span><span
                          style=3D"color:rgb(0,0,0)"><br>
                          =C2=A0 =C2=A0 </span><span style=3D"color:rgb(102=
,102,0)">};</span><span
                          style=3D"color:rgb(0,0,0)"><br>
                          =C2=A0 </span><span style=3D"color:rgb(102,102,0)=
">}</span><span
                          style=3D"color:rgb(0,0,0)"><br>
                        </span><span style=3D"color:rgb(102,102,0)">}</span=
><span
                          style=3D"color:rgb(0,0,0)"><br>
                          <br>
                        </span><span style=3D"color:rgb(0,0,136)">void</spa=
n><span
                          style=3D"color:rgb(0,0,0)"> f</span><span
                          style=3D"color:rgb(102,102,0)">()</span><span
                          style=3D"color:rgb(0,0,0)"> </span><span
                          style=3D"color:rgb(102,102,0)">{</span><span
                          style=3D"color:rgb(0,0,0)"><br>
                          =C2=A0 A</span><span style=3D"color:rgb(102,102,0=
)">::</span><span
                          style=3D"color:rgb(0,0,0)">B</span><span
                          style=3D"color:rgb(102,102,0)">::</span><span
                          style=3D"color:rgb(0,0,0)">X</span><span
                          style=3D"color:rgb(102,102,0)">::</span><span
                          style=3D"color:rgb(0,0,0)">Y</span><span
                          style=3D"color:rgb(102,102,0)">::</span><span
                          style=3D"color:rgb(0,0,0)">E </span><span
                          style=3D"color:rgb(0,0,136)">var</span><span
                          style=3D"color:rgb(0,0,0)"> </span><span
                          style=3D"color:rgb(102,102,0)">=3D</span><span
                          style=3D"color:rgb(0,0,0)"> e0</span><span
                          style=3D"color:rgb(102,102,0)">;</span><span
                          style=3D"color:rgb(0,0,0)"> =C2=A0 =C2=A0</span><=
span
                          style=3D"color:rgb(136,0,0)">// A::B::X::Y::E
                          var =3D A::B::X::Y::E::e0;</span><span
                          style=3D"color:rgb(0,0,0)"><br>
                          =C2=A0 </span><span style=3D"color:rgb(0,0,136)">=
if</span><span
                          style=3D"color:rgb(0,0,0)"> </span><font
                          color=3D"#666600"><span
                            style=3D"color:rgb(102,102,0)">(</span><span
                            style=3D"color:rgb(0,0,136)">var</span><span
                            style=3D"color:rgb(0,0,0)"> </span><span
                            style=3D"color:rgb(102,102,0)">=3D=3D</span><sp=
an
                            style=3D"color:rgb(0,0,0)"> e1</span><span
                            style=3D"color:rgb(102,102,0)">)</span><span
                            style=3D"color:rgb(0,0,0)"> =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 </span><span
                            style=3D"color:rgb(136,0,0)">// if (var =3D=3D
                            A::B::X::Y::E::e1)</span></font><span
                          style=3D"color:rgb(0,0,0)"><br>
                          =C2=A0 =C2=A0 </span><span style=3D"color:rgb(0,0=
,136)">var</span><span
                          style=3D"color:rgb(0,0,0)"> </span><span
                          style=3D"color:rgb(102,102,0)">=3D</span><span
                          style=3D"color:rgb(0,0,0)"> e2</span><span
                          style=3D"color:rgb(102,102,0)">;</span><span
                          style=3D"color:rgb(0,0,0)"> =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0</span><span
                          style=3D"color:rgb(136,0,0)">// =C2=A0 var =3D
                          A::B::X::Y::E::e2;</span><span
                          style=3D"color:rgb(0,0,0)"><br>
                          =C2=A0 </span><span style=3D"color:rgb(0,0,136)">=
switch</span><span
                          style=3D"color:rgb(0,0,0)"> </span><span
                          style=3D"color:rgb(102,102,0)">(</span><span
                          style=3D"color:rgb(0,0,136)">var</span><span
                          style=3D"color:rgb(102,102,0)">)</span><span
                          style=3D"color:rgb(0,0,0)"> </span><span
                          style=3D"color:rgb(102,102,0)">{</span><span
                          style=3D"color:rgb(0,0,0)"><br>
                          =C2=A0 </span><span style=3D"color:rgb(0,0,136)">=
case</span><span
                          style=3D"color:rgb(0,0,0)"> e</span><font
                          color=3D"#666600"><span style=3D"color:rgb(0,0,0)=
">0</span><span
                            style=3D"color:rgb(102,102,0)">:</span><span
                            style=3D"color:rgb(0,0,0)"> =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0
                          </span><span style=3D"color:rgb(136,0,0)">//
                            case A::B::X::Y::E::e0:</span><span
                            style=3D"color:rgb(0,0,0)"><br>
                          </span></font><span style=3D"color:rgb(0,0,0)">=
=C2=A0
                          =C2=A0 </span><span style=3D"color:rgb(0,0,136)">=
break</span><span
                          style=3D"color:rgb(102,102,0)">;</span><span
                          style=3D"color:rgb(0,0,0)"><br>
                          =C2=A0 </span><span style=3D"color:rgb(102,102,0)=
">}</span><span
                          style=3D"color:rgb(0,0,0)"><br>
                        </span><span
                          style=3D"color:rgb(102,102,0);font-family:Arial,H=
elvetica,sans-serif"><span
                            style=3D"color:rgb(102,102,0)">}</span></span><=
span
style=3D"color:rgb(136,0,0);font-family:Arial,Helvetica,sans-serif"><span
                            style=3D"color:rgb(0,0,0)"><br>
                          </span></span></div>
                    </code></div>
                  <br>
                  Would it be reasonable to allow this code?</div>
              </div>
            </blockquote>
            <div><br>
            </div>
            <div>+1 for `switch`, as for `=3D=3D`, maybe it'd be better to
              allows us to access the=C2=A0constant=C2=A0through variable, =
so we
              can write `var =3D=3D var.e1`.</div>
          </div>
        </div>
      </div>
    </blockquote>
    Currently, i believe we can do :<br>
    `var =3D=3D decltype(var)::e1`<br>
    <br>
  </body>
</html>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

--------------080609090005010600050202--

.


Author: corentin.schreiber@cea.fr
Date: Tue, 28 Oct 2014 12:26:23 -0700 (PDT)
Raw View
------=_Part_4905_1684930500.1414524383499
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Le mardi 28 octobre 2014 00:04:50 UTC+1, Kenshi Takayama a =C3=A9crit :
>
> Hi,
>
> I'm a big fan of the scoped enum feature introduced in C++11 since it=20
> avoids unintended mixing of enums and integers.
> However, I also find it redundant to have to type all its namespace/class=
=20
> scopes every time I compare or substitute some enum constant to another=
=20
> enum variable.
> For example, I'd like the following code to work:
>
> namespace A {
>   namespace B {
>     struct X {
>       struct Y {
>         enum struct E {
>           e0,
>           e1,
>           e2,
>         };
>       };
>     };
>   }
> }
>
> void f() {
>   A::B::X::Y::E var =3D e0;    // A::B::X::Y::E var =3D A::B::X::Y::E::e0=
;
>   if (var =3D=3D e1)             // if (var =3D=3D A::B::X::Y::E::e1)
>     var =3D e2;                //   var =3D A::B::X::Y::E::e2;
>   switch (var) {
>   case e0:                   // case A::B::X::Y::E::e0:
>     break;
>   }
> }
>
> Would it be reasonable to allow this code?
>
> Thanks,
> Kenshi
>

I have brought up a similar suggestion a few months ago:
https://groups.google.com/a/isocpp.org/d/topic/std-proposals/f-P2TENSAaU/di=
scussion=20

There are interesting discussions in this thread, in particular regarding=
=20
the connection with other proposals (in particular "function local=20
enumerations").

Working out the switch, initialization and assignment should be=20
straightforward. The switch case can be seen as a special case of=20
initialization, if one considers that the expression after the "case"=20
keyword is used to initialize a temporary and hidden variable whose type is=
=20
that of the switch argument.

Here is one way to implement the lookup. When initializing (or assigning) a=
=20
variable of enumeration type, first look for a candidate in the local scope=
=20
(so as to preserve backward compatibility), then if none is found, try=20
within the name space of the object (the switch argument, the initialized=
=20
variable, and the variable that is assigned to, respectively). After that,=
=20
if no candidate match, then the program is ill-formed as usual.
To preserve backward compatibility, there must be no ambiguity: if both a=
=20
local variable and an enumerator have the same identifier, and if the local=
=20
variable has (or is convertible to) the enumeration type, the local=20
variable is preferred (by "local", I mean everything that is already in the=
=20
current name space, either because it has been declared there, or because=
=20
it has been imported by a 'using namespace' directive). Compilers should=20
perhaps issue a warning about shadowing in this case.

The comparison operator is more troublesome, but it can also be done if we=
=20
add a special rule regarding the usage of enumeration types in comparison=
=20
operators. This would be some sort of argument dependent lookup (ADL).
When a comparison operator is found, the arguments are scanned with a first=
=20
identifier resolution pass. If all identifier are resolved, fine, do as=20
usual. If one of the two arguments could not be resolved, we look at the=20
type of the other one. If it is of enumeration type, we search for the=20
missing identifier in the scope of the enumeration. If the identifier is=20
found, the missing identifier is resolved. In all other cases, the program=
=20
is ill-formed.

--=20

---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.

------=_Part_4905_1684930500.1414524383499
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Le mardi 28 octobre 2014 00:04:50 UTC+1, Kenshi Takayama a=
 =C3=A9crit&nbsp;:<blockquote class=3D"gmail_quote" style=3D"margin: 0;marg=
in-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"=
ltr">Hi,<div><br></div><div>I'm a big fan of the scoped enum feature introd=
uced in C++11 since it avoids unintended mixing of enums and integers.</div=
><div>However, I also find it redundant to have to type all its namespace/c=
lass scopes every time I compare or substitute some enum constant to anothe=
r enum variable.</div><div>For example, I'd like the following code to work=
:</div><div><br></div><div><div style=3D"border:1px solid rgb(187,187,187);=
word-wrap:break-word;background-color:rgb(250,250,250)"><code><div><span st=
yle=3D"color:#008">namespace</span><span style=3D"color:#000"> A </span><sp=
an style=3D"color:#660">{</span><span style=3D"color:#000"><br>&nbsp; </spa=
n><span style=3D"color:#008">namespace</span><span style=3D"color:#000"> B =
</span><span style=3D"color:#660">{</span><span style=3D"color:#000"><br>&n=
bsp; &nbsp; </span><span style=3D"color:#008">struct</span><span style=3D"c=
olor:#000"> X </span><span style=3D"color:#660">{</span><span style=3D"colo=
r:#000"><br>&nbsp; &nbsp; &nbsp; </span><span style=3D"color:#008">struct</=
span><span style=3D"color:#000"> Y </span><span style=3D"color:#660">{</spa=
n><span style=3D"color:#000"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span s=
tyle=3D"color:#008">enum</span><span style=3D"color:#000"> </span><span sty=
le=3D"color:#008">struct</span><span style=3D"color:#000"> E </span><span s=
tyle=3D"color:#660">{</span><span style=3D"color:#000"><br>&nbsp; &nbsp; &n=
bsp; &nbsp; &nbsp; e0</span><span style=3D"color:#660">,</span><span style=
=3D"color:#000"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; e1</span><span style=
=3D"color:#660">,</span><span style=3D"color:#000"><br>&nbsp; &nbsp; &nbsp;=
 &nbsp; &nbsp; e2</span><span style=3D"color:#660">,</span><span style=3D"c=
olor:#000"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style=3D"color:#660=
">};</span><span style=3D"color:#000"><br>&nbsp; &nbsp; &nbsp; </span><span=
 style=3D"color:#660">};</span><span style=3D"color:#000"><br>&nbsp; &nbsp;=
 </span><span style=3D"color:#660">};</span><span style=3D"color:#000"><br>=
&nbsp; </span><span style=3D"color:#660">}</span><span style=3D"color:#000"=
><br></span><span style=3D"color:#660">}</span><span style=3D"color:#000"><=
br><br></span><span style=3D"color:#008">void</span><span style=3D"color:#0=
00"> f</span><span style=3D"color:#660">()</span><span style=3D"color:#000"=
> </span><span style=3D"color:#660">{</span><span style=3D"color:#000"><br>=
&nbsp; A</span><span style=3D"color:#660">::</span><span style=3D"color:#00=
0">B</span><span style=3D"color:#660">::</span><span style=3D"color:#000">X=
</span><span style=3D"color:#660">::</span><span style=3D"color:#000">Y</sp=
an><span style=3D"color:#660">::</span><span style=3D"color:#000">E </span>=
<span style=3D"color:#008">var</span><span style=3D"color:#000"> </span><sp=
an style=3D"color:#660">=3D</span><span style=3D"color:#000"> e0</span><spa=
n style=3D"color:#660">;</span><span style=3D"color:#000"> &nbsp; &nbsp;</s=
pan><span style=3D"color:#800">// A::B::X::Y::E var =3D A::B::X::Y::E::e0;<=
/span><span style=3D"color:#000"><br>&nbsp; </span><span style=3D"color:#00=
8">if</span><span style=3D"color:#000"> </span><font color=3D"#666600"><spa=
n style=3D"color:#660">(</span><span style=3D"color:#008">var</span><span s=
tyle=3D"color:#000"> </span><span style=3D"color:#660">=3D=3D</span><span s=
tyle=3D"color:#000"> e1</span><span style=3D"color:#660">)</span><span styl=
e=3D"color:#000"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span st=
yle=3D"color:#800">// if (var =3D=3D A::B::X::Y::E::e1)</span></font><span =
style=3D"color:#000"><br>&nbsp; &nbsp; </span><span style=3D"color:#008">va=
r</span><span style=3D"color:#000"> </span><span style=3D"color:#660">=3D</=
span><span style=3D"color:#000"> e2</span><span style=3D"color:#660">;</spa=
n><span style=3D"color:#000"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nb=
sp; &nbsp;</span><span style=3D"color:#800">// &nbsp; var =3D A::B::X::Y::E=
::e2;</span><span style=3D"color:#000"><br>&nbsp; </span><span style=3D"col=
or:#008">switch</span><span style=3D"color:#000"> </span><span style=3D"col=
or:#660">(</span><span style=3D"color:#008">var</span><span style=3D"color:=
#660">)</span><span style=3D"color:#000"> </span><span style=3D"color:#660"=
>{</span><span style=3D"color:#000"><br>&nbsp; </span><span style=3D"color:=
#008">case</span><span style=3D"color:#000"> e</span><font color=3D"#666600=
"><span style=3D"color:#000">0</span><span style=3D"color:#660">:</span><sp=
an style=3D"color:#000"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &=
nbsp; &nbsp; </span><span style=3D"color:#800">// case A::B::X::Y::E::e0:</=
span><span style=3D"color:#000"><br></span></font><span style=3D"color:#000=
">&nbsp; &nbsp; </span><span style=3D"color:#008">break</span><span style=
=3D"color:#660">;</span><span style=3D"color:#000"><br>&nbsp; </span><span =
style=3D"color:#660">}</span><span style=3D"color:#000"><br></span><span st=
yle=3D"color:rgb(102,102,0);font-family:Arial,Helvetica,sans-serif"><span s=
tyle=3D"color:#660">}</span></span><span style=3D"color:rgb(136,0,0);font-f=
amily:Arial,Helvetica,sans-serif"><span style=3D"color:#000"><br></span></s=
pan></div></code></div><br>Would it be reasonable to allow this code?</div>=
<div><br></div><div>Thanks,</div><div>Kenshi</div></div></blockquote><div><=
br>I have brought up a similar suggestion a few months ago:<br>https://grou=
ps.google.com/a/isocpp.org/d/topic/std-proposals/f-P2TENSAaU/discussion <br=
>There are interesting discussions in this thread, in particular regarding =
the connection with other proposals (in particular "function local enumerat=
ions").<br><br>Working out the switch, initialization and assignment should=
 be straightforward. The switch case can be seen as a special case of initi=
alization, if one considers that the expression after the "case" keyword is=
 used to initialize a temporary and hidden variable whose type is that of t=
he switch argument.<br><br>Here is one way to implement the lookup. When in=
itializing (or assigning) a variable of enumeration type, first look for a =
candidate in the local scope (so as to preserve backward compatibility), th=
en if none is found, try within the name space of the object (the switch ar=
gument, the initialized variable, and the variable that is assigned to, res=
pectively). After that, if no candidate match, then the program is ill-form=
ed as usual.<br>To preserve backward compatibility, there must be no ambigu=
ity: if both a local variable and an enumerator have the same identifier, a=
nd if the local variable has (or is convertible to) the enumeration type, t=
he local variable is preferred (by "local", I mean everything that is alrea=
dy in the current name space, either because it has been declared there, or=
 because it has been imported by a 'using namespace' directive). Compilers =
should perhaps issue a warning about shadowing in this case.<br><br>The com=
parison operator is more troublesome, but it can also be done if we add a s=
pecial rule regarding the usage of enumeration types in comparison operator=
s. This would be some sort of argument dependent lookup (ADL).<br>When a co=
mparison operator is found, the arguments are scanned with a first identifi=
er resolution pass. If all identifier are resolved, fine, do as usual. If o=
ne of the two arguments could not be resolved, we look at the type of the o=
ther one. If it is of enumeration type, we search for the missing identifie=
r in the scope of the enumeration. If the identifier is found, the missing =
identifier is resolved. In all other cases, the program is ill-formed.<br><=
/div></div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_4905_1684930500.1414524383499--

.


Author: Thiago Macieira <thiago@macieira.org>
Date: Tue, 28 Oct 2014 12:34:06 -0700
Raw View
On Tuesday 28 October 2014 12:26:23 corentin.schreiber@cea.fr wrote:
> Here is one way to implement the lookup. When initializing (or assigning) a
> variable of enumeration type, first look for a candidate in the local scope
> (so as to preserve backward compatibility), then if none is found, try
> within the name space of the object (the switch argument, the initialized
> variable, and the variable that is assigned to, respectively).

That means looking up the target variable type, across the initialisation.
That's a major language change.

--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel Open Source Technology Center
      PGP/GPG: 0x6EF45358; fingerprint:
      E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

.


Author: Myriachan <myriachan@gmail.com>
Date: Tue, 28 Oct 2014 13:39:41 -0700 (PDT)
Raw View
------=_Part_2163_628881710.1414528782015
Content-Type: text/plain; charset=UTF-8

On Tuesday, October 28, 2014 12:34:12 PM UTC-7, Thiago Macieira wrote:
>
> On Tuesday 28 October 2014 12:26:23 corentin....@cea.fr <javascript:>
> wrote:
> > Here is one way to implement the lookup. When initializing (or
> assigning) a
> > variable of enumeration type, first look for a candidate in the local
> scope
> > (so as to preserve backward compatibility), then if none is found, try
> > within the name space of the object (the switch argument, the
> initialized
> > variable, and the variable that is assigned to, respectively).
>
> That means looking up the target variable type, across the initialisation.
> That's a major language change.
>
>
I previously wanted to propose a "using namespace" extension, where you
could specify a class name or enum name rather than just namespaces, but
this thread looks like a similar topic, so I'll mention what I was going to
propose.

With an extended "using namespace", the above case would then reduce to:

namespace A {
  namespace B {
    struct X {
      struct Y {
        enum struct E {
          e0,
          e1,
          e2,
        };
      };
    };
  }
}

void f() {
  using namespace A::B::X::Y::E;
  A::B::X::Y::E var = e0;    // A::B::X::Y::E var = A::B::X::Y::E::e0;
  if (var == e1)             // if (var == A::B::X::Y::E::e1)
    var = e2;                //   var = A::B::X::Y::E::e2;
  switch (var) {
  case e0:                   // case A::B::X::Y::E::e0:
    break;
  }
}

Melissa

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

------=_Part_2163_628881710.1414528782015
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On Tuesday, October 28, 2014 12:34:12 PM UTC-7, Thiago Mac=
ieira wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-lef=
t: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">On Tuesday 28 Octo=
ber 2014 12:26:23 <a href=3D"javascript:" target=3D"_blank" gdf-obfuscated-=
mailto=3D"5o1A4W79LvsJ" onmousedown=3D"this.href=3D'javascript:';return tru=
e;" onclick=3D"this.href=3D'javascript:';return true;">corentin....@cea.fr<=
/a> wrote:
<br>&gt; Here is one way to implement the lookup. When initializing (or ass=
igning) a=20
<br>&gt; variable of enumeration type, first look for a candidate in the lo=
cal scope
<br>&gt; (so as to preserve backward compatibility), then if none is found,=
 try
<br>&gt; within the name space of the object (the switch argument, the init=
ialized
<br>&gt; variable, and the variable that is assigned to, respectively).
<br>
<br>That means looking up the target variable type, across the initialisati=
on.=20
<br>That's a major language change.
<br>
<br></blockquote><div><br>I previously wanted to propose a "using namespace=
" extension, where you could specify a class name or enum name rather than =
just namespaces, but this thread looks like a similar topic, so I'll mentio=
n what I was going to propose.<br><br>With an extended "using namespace", t=
he above case would then reduce to:<br><br><div class=3D"prettyprint" style=
=3D"background-color: rgb(250, 250, 250); border-color: rgb(187, 187, 187);=
 border-style: solid; border-width: 1px; word-wrap: break-word;"><code clas=
s=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"color: #008;=
" class=3D"styled-by-prettify">namespace</span><span style=3D"color: #000;"=
 class=3D"styled-by-prettify"> A </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"><br>&nbsp; </span><span style=3D"color: #008;" class=3D"styl=
ed-by-prettify">namespace</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> B </span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><=
br>&nbsp; &nbsp; </span><span style=3D"color: #008;" class=3D"styled-by-pre=
ttify">struct</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> X </span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &n=
bsp; &nbsp; </span><span style=3D"color: #008;" class=3D"styled-by-prettify=
">struct</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> Y=
 </span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; =
&nbsp; &nbsp; </span><span style=3D"color: #008;" class=3D"styled-by-pretti=
fy">enum</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> <=
/span><span style=3D"color: #008;" class=3D"styled-by-prettify">struct</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> E </span><span=
 style=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; &nbsp; &nbsp;=
 &nbsp; e0</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp=
; &nbsp; &nbsp; &nbsp; &nbsp; e1</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; e2</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; &nbsp; &nbsp; </spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">};</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; &nbsp=
; </span><span style=3D"color: #660;" class=3D"styled-by-prettify">};</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp=
; </span><span style=3D"color: #660;" class=3D"styled-by-prettify">};</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; </spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">}</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">}</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #008;" cla=
ss=3D"styled-by-prettify">void</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> f</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">()</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; </s=
pan><span style=3D"color: #008;" class=3D"styled-by-prettify">using</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span styl=
e=3D"color: #008;" class=3D"styled-by-prettify">namespace</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> A</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">::</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify">B</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">::</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify">X</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">::</span><span style=3D"color: #000;" class=3D"styled-by-prettify">Y=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">::</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify">E</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"><br>&nbsp; A</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">::</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify">B</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">::</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify">X</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">::</span><span style=3D"color: #000;" class=3D"styled-by-prettify">Y=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">::</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify">E </span><span sty=
le=3D"color: #008;" class=3D"styled-by-prettify">var</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> e0</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> &nbsp; &nbsp;</span><span style=3D"color: #800;" class=3D"styled=
-by-prettify">// A::B::X::Y::E var =3D A::B::X::Y::E::e0;</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; </span><span styl=
e=3D"color: #008;" class=3D"styled-by-prettify">if</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">(</span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">var</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">=3D=3D</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> e1</span><span style=3D"color: #660;" class=3D"styled-by-prettify">)</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> &nbsp; &nbs=
p; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style=3D"color: #800;" class=3D=
"styled-by-prettify">// if (var =3D=3D A::B::X::Y::E::e1)</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; </span><sp=
an style=3D"color: #008;" class=3D"styled-by-prettify">var</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> e2</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</s=
pan><span style=3D"color: #800;" class=3D"styled-by-prettify">// &nbsp; var=
 =3D A::B::X::Y::E::e2;</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"><br>&nbsp; </span><span style=3D"color: #008;" class=3D"styled=
-by-prettify">switch</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>(</span><span style=3D"color: #008;" class=3D"styled-by-prettify">var</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">)</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">{</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"><br>&nbsp; </span><span style=3D"color: #0=
08;" class=3D"styled-by-prettify">case</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> e0</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">:</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;=
 </span><span style=3D"color: #800;" class=3D"styled-by-prettify">// case A=
::B::X::Y::E::e0:</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"><br>&nbsp; &nbsp; </span><span style=3D"color: #008;" class=3D"style=
d-by-prettify">break</span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
><br>&nbsp; </span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">}</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">}</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify"><br></span></div></cod=
e></div><br>Melissa<br></div></div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_2163_628881710.1414528782015--

.


Author: Thiago Macieira <thiago@macieira.org>
Date: Tue, 28 Oct 2014 14:09:12 -0700
Raw View
On Tuesday 28 October 2014 13:39:41 Myriachan wrote:
> I previously wanted to propose a "using namespace" extension, where you
> could specify a class name or enum name rather than just namespaces, but
> this thread looks like a similar topic, so I'll mention what I was going to
> propose.

That would be ok, from my point of view. Just as long as people understand
this brings into scope only the parts of the class that don't require an
object -- that is not a "with" directive.

> With an extended "using namespace", the above case would then reduce to:
>
> namespace A {
>   namespace B {
>     struct X {
>       struct Y {
>         enum struct E {
>           e0,
>           e1,
>           e2,
>         };
>       };
>     };
>   }
> }
>
> void f() {
>   using namespace A::B::X::Y::E;
>   A::B::X::Y::E var = e0;    // A::B::X::Y::E var = A::B::X::Y::E::e0;
>   if (var == e1)             // if (var == A::B::X::Y::E::e1)
>     var = e2;                //   var = A::B::X::Y::E::e2;
>   switch (var) {
>   case e0:                   // case A::B::X::Y::E::e0:
>     break;
>   }
> }

That would be fine in my opinion.

What I don't think would fly is to do that without the using declaration.
Corentin's proposal would imply that this is also valid:

 (A::B::X::Y::E)e0

It would introduce context-dependent lookups.

--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel Open Source Technology Center
      PGP/GPG: 0x6EF45358; fingerprint:
      E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

.


Author: corentin.schreiber@cea.fr
Date: Tue, 28 Oct 2014 15:02:40 -0700 (PDT)
Raw View
------=_Part_5962_550472898.1414533761000
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Le mardi 28 octobre 2014 21:39:42 UTC+1, Myriachan a =C3=A9crit :
>
> On Tuesday, October 28, 2014 12:34:12 PM UTC-7, Thiago Macieira wrote:
>>
>> On Tuesday 28 October 2014 12:26:23 corentin....@cea.fr wrote:=20
>> > Here is one way to implement the lookup. When initializing (or=20
>> assigning) a=20
>> > variable of enumeration type, first look for a candidate in the local=
=20
>> scope=20
>> > (so as to preserve backward compatibility), then if none is found, try=
=20
>> > within the name space of the object (the switch argument, the=20
>> initialized=20
>> > variable, and the variable that is assigned to, respectively).=20
>>
>> That means looking up the target variable type, across the=20
>> initialisation.=20
>> That's a major language change.=20
>>
>>
> I previously wanted to propose a "using namespace" extension, where you=
=20
> could specify a class name or enum name rather than just namespaces, but=
=20
> this thread looks like a similar topic, so I'll mention what I was going =
to=20
> propose.
>

For the record:
https://groups.google.com/a/isocpp.org/d/topic/std-proposals/-3Q3C5FPuPE/di=
scussion
:)

As for being a major language change Thiago, I do not understand why you=20
say so (nor do I know the consequences it implies). Isn't this similar to=
=20
something we already have in the language: ADL?

I'm no norm or compiler writer, so maybe it is indeed major in the way that=
=20
it violates root concepts of C++, but I would say that from a user point of=
=20
view this does not seem major at all. Philosophically, this is the same as=
=20
writing:
struct A {
    A(int) {}
};

A a =3D 2;
.... in the sense that '2' is understood in the context of initializing 'a'.=
=20
Do not get me wrong: I do know that, technically speaking, whatever is on=
=20
the right hand side of the equal sign is currently syntactically valid on=
=20
its own, and forwarded as is to the constructor of A. For the compiler, the=
=20
'2' here has nothing special, it is always the literal integer of value 2,=
=20
no matter what is present on the left hand side of the equal sign. But my=
=20
point is that, for the person reading the code, this is not true. To=20
actually understand this '2', the user will look at the type of 'a'.=20
Therefore I'm quite sure that interpreting an identifier on the rhs=20
depending on the type of the lhs will appear natural to most people. But=20
maybe that is not what you meant.

--=20

---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.

------=_Part_5962_550472898.1414533761000
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Le mardi 28 octobre 2014 21:39:42 UTC+1, Myriachan a =C3=
=A9crit&nbsp;:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-l=
eft: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"=
>On Tuesday, October 28, 2014 12:34:12 PM UTC-7, Thiago Macieira wrote:<blo=
ckquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-le=
ft:1px #ccc solid;padding-left:1ex">On Tuesday 28 October 2014 12:26:23 <a>=
corentin....@cea.fr</a> wrote:
<br>&gt; Here is one way to implement the lookup. When initializing (or ass=
igning) a=20
<br>&gt; variable of enumeration type, first look for a candidate in the lo=
cal scope
<br>&gt; (so as to preserve backward compatibility), then if none is found,=
 try
<br>&gt; within the name space of the object (the switch argument, the init=
ialized
<br>&gt; variable, and the variable that is assigned to, respectively).
<br>
<br>That means looking up the target variable type, across the initialisati=
on.=20
<br>That's a major language change.
<br>
<br></blockquote><div><br>I previously wanted to propose a "using namespace=
" extension, where you could specify a class name or enum name rather than =
just namespaces, but this thread looks like a similar topic, so I'll mentio=
n what I was going to propose.<br></div></div></blockquote><div><br>For the=
 record:<br>https://groups.google.com/a/isocpp.org/d/topic/std-proposals/-3=
Q3C5FPuPE/discussion<br>:)<br><br>As for being a major language change Thia=
go, I do not understand why you say so (nor do I know the consequences it i=
mplies). Isn't this similar to something we already have in the language: A=
DL?<br><br>I'm no norm or compiler writer, so maybe it is indeed major in t=
he way that it violates root concepts of C++, but I would say that from a u=
ser point of view this does not seem major at all. Philosophically, this is=
 the same as writing:<br><div class=3D"prettyprint" style=3D"background-col=
or: rgb(250, 250, 250); border-color: rgb(187, 187, 187); border-style: sol=
id; border-width: 1px; word-wrap: break-word;"><code class=3D"prettyprint">=
<div class=3D"subprettyprint"><span style=3D"color: #008;" class=3D"styled-=
by-prettify">struct</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> A </span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nb=
sp; &nbsp; A</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">(</span><span style=3D"color: #008;" class=3D"styled-by-prettify">int</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">)</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">{}</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">};</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"><br><br>A a </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> </span><span style=3D"color: #066;" class=3D"styled-by-pr=
ettify">2</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;=
</span></div></code></div>... in the sense that '2'  is understood in the c=
ontext of initializing 'a'. Do not get me wrong: I do know that, technicall=
y speaking, whatever is on the right hand side of the equal sign is current=
ly syntactically valid on its own, and forwarded as is to the constructor o=
f A. For the compiler, the '2' here has nothing special, it is always the l=
iteral integer of value 2, no matter what is present on the left hand side =
of the equal sign. But my point is that, for the person reading the code, t=
his is not true. To actually understand this '2', the user will look at the=
 type of 'a'. Therefore I'm quite sure that interpreting an identifier on t=
he rhs depending on the type of the lhs will appear natural to most people.=
 But maybe that is not what you meant.<br></div></div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_5962_550472898.1414533761000--

.


Author: Thiago Macieira <thiago@macieira.org>
Date: Tue, 28 Oct 2014 15:55:08 -0700
Raw View
On Tuesday 28 October 2014 15:02:40 corentin.schreiber@cea.fr wrote:
> As for being a major language change Thiago, I do not understand why you
> say so (nor do I know the consequences it implies). Isn't this similar to
> something we already have in the language: ADL?

Yes and no.

It's quite different from ADL in the details. For ADL to trigger, you need to
have the template parameter somewhere in the expression.

But it's similar that it depends on how it's used. And the fact that ADL was
such a simple idea that triggered an enormity of complexity for compiler
writers and the standard. There are still modern compilers today that do not
implement ADL correctly. If your proposal is half as complex as ADL, it's
still a major language change.

> I'm no norm or compiler writer, so maybe it is indeed major in the way that
> it violates root concepts of C++, but I would say that from a user point of
> view this does not seem major at all. Philosophically, this is the same as
> writing:
> struct A {
>     A(int) {}
> };
>
> A a = 2;
> ... in the sense that '2' is understood in the context of initializing 'a'.

That's not the same. The compiler knows that 2 is an integer literal. It also
knows that there's an assignment, so it only needs to find the constructor or
operator= overload that will take the integer literal.

What you're asking for calls for:

 A a = token;

And "token" cannot be interpreted until you resolve the left side. That's a
huge change of the language: you can't select the overload of the constructor
or operator= until you know the token, but you can't resolve the token until
you've selected the overload. The compiler would have to try all overloads and
check which one(s) compile, and then do overload resolution.

Additionally, the original case is equivalent to:

 decltype(auto) tmp = 2;
 A a = std::move(tmp);

But your case can't be written as:

 decltype(auto) tmp = token;
 A a = std::move(tmp);

Because token can't be resolved to an actual type.

> Do not get me wrong: I do know that, technically speaking, whatever is on
> the right hand side of the equal sign is currently syntactically valid on
> its own, and forwarded as is to the constructor of A. For the compiler, the
> '2' here has nothing special, it is always the literal integer of value 2,
> no matter what is present on the left hand side of the equal sign. But my
> point is that, for the person reading the code, this is not true. To
> actually understand this '2', the user will look at the type of 'a'.

That's incorrect. It *is* an integer of value 2. It has no other meaning. What
semantic the value 2 has for the object A is not relevant at this point.

> Therefore I'm quite sure that interpreting an identifier on the rhs
> depending on the type of the lhs will appear natural to most people. But
> maybe that is not what you meant.

I disagree that it's natural because I disagreed with your last point.

--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel Open Source Technology Center
      PGP/GPG: 0x6EF45358; fingerprint:
      E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

.


Author: Myriachan <myriachan@gmail.com>
Date: Tue, 28 Oct 2014 16:01:02 -0700 (PDT)
Raw View
------=_Part_6_1566415358.1414537262502
Content-Type: text/plain; charset=UTF-8

On Tuesday, October 28, 2014 2:09:17 PM UTC-7, Thiago Macieira wrote:
>
> On Tuesday 28 October 2014 13:39:41 Myriachan wrote:
> > I previously wanted to propose a "using namespace" extension, where you
> > could specify a class name or enum name rather than just namespaces, but
> > this thread looks like a similar topic, so I'll mention what I was going
> to
> > propose.
>
> That would be ok, from my point of view. Just as long as people understand
> this brings into scope only the parts of the class that don't require an
> object -- that is not a "with" directive.
>
>
Agreed there.


> > With an extended "using namespace", the above case would then reduce to:
> > ...
> > void f() {
> >   using namespace A::B::X::Y::E;
> >   A::B::X::Y::E var = e0;    // A::B::X::Y::E var = A::B::X::Y::E::e0;
> >   if (var == e1)             // if (var == A::B::X::Y::E::e1)
> >     var = e2;                //   var = A::B::X::Y::E::e2;
> >   switch (var) {
> >   case e0:                   // case A::B::X::Y::E::e0:
> >     break;
> >   }
> > }
>
> That would be fine in my opinion.
>
> What I don't think would fly is to do that without the using declaration.
> Corentin's proposal would imply that this is also valid:
>
>         (A::B::X::Y::E)e0
>
> It would introduce context-dependent lookups.
>

Also agreed.

The one thing I don't completely like about my syntax is using the keyword
"namespace" with classes and enums.  I would have thought that "enum
class/struct/union/enum T" would've already been valid syntaxes, but
apparently not.

So would "using namespace SomeEnum" or "using enum SomeEnum" be better?
One implies that you're using the *namespace* of SomeEnum, and means
essentially the same as current "using namespace".  The other makes more
sense from the perspective that SomeEnum is an enum, not a namespace.

Melissa

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

------=_Part_6_1566415358.1414537262502
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On Tuesday, October 28, 2014 2:09:17 PM UTC-7, Thiago Maci=
eira wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left=
: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">On Tuesday 28 Octob=
er 2014 13:39:41 Myriachan wrote:
<br>&gt; I previously wanted to propose a "using namespace" extension, wher=
e you
<br>&gt; could specify a class name or enum name rather than just namespace=
s, but
<br>&gt; this thread looks like a similar topic, so I'll mention what I was=
 going to
<br>&gt; propose.
<br>
<br>That would be ok, from my point of view. Just as long as people underst=
and=20
<br>this brings into scope only the parts of the class that don't require a=
n=20
<br>object -- that is not a "with" directive.
<br>
<br></blockquote><div><br>Agreed there.<br>&nbsp;</div><blockquote class=3D=
"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc s=
olid;padding-left: 1ex;">&gt; With an extended "using namespace", the above=
 case would then reduce to:
<br>&gt;=20
....<br>&gt; void f() {
<br>&gt; &nbsp; using namespace A::B::X::Y::E;
<br>&gt; &nbsp; A::B::X::Y::E var =3D e0; &nbsp; &nbsp;// A::B::X::Y::E var=
 =3D A::B::X::Y::E::e0;
<br>&gt; &nbsp; if (var =3D=3D e1) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp=
; // if (var =3D=3D A::B::X::Y::E::e1)
<br>&gt; &nbsp; &nbsp; var =3D e2; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp=
; &nbsp; &nbsp;// &nbsp; var =3D A::B::X::Y::E::e2;
<br>&gt; &nbsp; switch (var) {
<br>&gt; &nbsp; case e0: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &=
nbsp; &nbsp; // case A::B::X::Y::E::e0:
<br>&gt; &nbsp; &nbsp; break;
<br>&gt; &nbsp; }
<br>&gt; }
<br>
<br>That would be fine in my opinion.
<br>
<br>What I don't think would fly is to do that without the using declaratio=
n.=20
<br>Corentin's proposal would imply that this is also valid:
<br>
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(A::B::X::Y::E)e0
<br>
<br>It would introduce context-dependent lookups.
<br>
</blockquote><div><br>Also agreed.<br><br>The one thing I don't completely =
like about my syntax is using the keyword "namespace" with classes and enum=
s.&nbsp; I would have thought that "enum class/struct/union/enum T" would'v=
e already been valid syntaxes, but apparently not.<br><br>So would "using n=
amespace SomeEnum" or "using enum SomeEnum" be better?&nbsp; One implies th=
at you're using the *namespace* of SomeEnum, and means essentially the same=
 as current "using namespace".&nbsp; The other makes more sense from the pe=
rspective that SomeEnum is an enum, not a namespace.<br><br>Melissa<br></di=
v></div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_6_1566415358.1414537262502--

.


Author: Jens Maurer <Jens.Maurer@gmx.net>
Date: Wed, 29 Oct 2014 07:35:21 +0100
Raw View
On 10/28/2014 11:02 PM, corentin.schreiber@cea.fr wrote:
> As for being a major language change Thiago, I do not understand why you say so (nor do I know the consequences it implies).

There is no formal classification for something being a "major change".

However, properly specifying what you want to achieve, including
its interactions with overload resolution and overloaded operators,
seems like no small task.  I doubt the invested effort (including
review effort within WG21) is worth the return.

I can be convinced otherwise; please show me reasonably solid core
language wording (as a change to the current standard/working draft)
that implements your proposal.

Thanks,
Jens

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

.


Author: Thibaut Lutz <thibaut.lutz@googlemail.com>
Date: Wed, 29 Oct 2014 09:58:52 +0000
Raw View
--001a11402fbcd6cfff05068cd069
Content-Type: text/plain; charset=UTF-8

At the risk of repeating myself, what is the advantage of using namespace A
::B::X::Y::E over using E = A::B::X::Y::E? Sure in the latter one has to
type three extra characters to use E::e0, but this burden is largely
outweigh by the benefits of avoiding ambiguity and providing type safety,
plus the code is clearer. Giving a way to pull the enumerators out of the
scope entirely to me seems to defy the purpose of the scoped enums and
would introduce ambiguous cases. Consider the example below:

namespace A {

  namespace B {

    struct X {

      struct Y {

        enum struct E : int {

          e0 = 1, e1, e2,

        };

      };

    };

  }

}


int main() {

  using E = A::B::X::Y::E;

  A::B::X::Y::E var = E::e0;

    // This should be legal with the suggested resolution

  using namespace A::B::X::Y::E;

  if(var == e0){}

  if((int)var == (int)e0){} // then so is this

    int e0 = 123; // introducing an int with the same identifier


  // current unambiguous notation

  if((int)var == (int)decltype(var)::e0){} // ok: if var == 1

  if((int)var == (int)E::e0){} // ok: if var == 1

  if((int)var == e0){} // ok: if var == 123


  // suggested notation ambiguities

  if((int)var == (int)e0){} // ??

  if((int)e0 == (int)var){} // ??


  switch(var) { case e0: ; }

  switch((int)var) { case e0: ; } // ??

  switch((int)var) { case (int)e0: ; } // ??

}


This could get sorted by prioritizing one lookup over the other, but I
don't see any universal way of doing this; a resolution ordering that seems
logical to some might not be to others. In any case it makes the code more
fragile since it would allow either a variable to shadow a scoped
enumerator or a scoped enumerator to shadow a variable.

On Wed, Oct 29, 2014 at 6:35 AM, Jens Maurer <Jens.Maurer@gmx.net> wrote:

> On 10/28/2014 11:02 PM, corentin.schreiber@cea.fr wrote:
> > As for being a major language change Thiago, I do not understand why you
> say so (nor do I know the consequences it implies).
>
> There is no formal classification for something being a "major change".
>
> However, properly specifying what you want to achieve, including
> its interactions with overload resolution and overloaded operators,
> seems like no small task.  I doubt the invested effort (including
> review effort within WG21) is worth the return.
>
> I can be convinced otherwise; please show me reasonably solid core
> language wording (as a change to the current standard/working draft)
> that implements your proposal.
>
> Thanks,
> Jens
>
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "ISO C++ Standard - Future Proposals" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to std-proposals+unsubscribe@isocpp.org.
> To post to this group, send email to std-proposals@isocpp.org.
> Visit this group at
> http://groups.google.com/a/isocpp.org/group/std-proposals/.
>



--
Thibaut LUTZ

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

--001a11402fbcd6cfff05068cd069
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">At the risk of repeating myself, what is the advantage of=
=C2=A0<span style=3D"color:rgb(128,128,0)">using</span><span style=3D"color=
:rgb(192,192,192)"> </span><span style=3D"color:rgb(128,128,0)">namespace</=
span><span style=3D"color:rgb(192,192,192)"> </span><span style=3D"color:rg=
b(128,0,128)">A</span><span style=3D"color:rgb(0,0,0)">::</span><span style=
=3D"color:rgb(128,0,128)">B</span><span style=3D"color:rgb(0,0,0)">::</span=
><span style=3D"color:rgb(128,0,128)">X</span><span style=3D"color:rgb(0,0,=
0)">::</span><span style=3D"color:rgb(128,0,128)">Y</span><span style=3D"co=
lor:rgb(0,0,0)">::</span><span style=3D"color:rgb(128,0,128)">E</span>=C2=
=A0over=C2=A0<span style=3D"color:rgb(128,128,0)">using</span><span style=
=3D"color:rgb(192,192,192)"> </span><span style=3D"color:rgb(128,0,128)">E<=
/span><span style=3D"color:rgb(192,192,192)"> </span><span style=3D"color:r=
gb(0,0,0)">=3D</span><span style=3D"color:rgb(192,192,192)"> </span><span s=
tyle=3D"color:rgb(128,0,128)">A</span><span style=3D"color:rgb(0,0,0)">::</=
span><span style=3D"color:rgb(128,0,128)">B</span><span style=3D"color:rgb(=
0,0,0)">::</span><span style=3D"color:rgb(128,0,128)">X</span><span style=
=3D"color:rgb(0,0,0)">::</span><span style=3D"color:rgb(128,0,128)">Y</span=
><span style=3D"color:rgb(0,0,0)">::</span><span style=3D"color:rgb(128,0,1=
28)">E</span>? Sure in the latter one has to type three extra characters to=
 use=C2=A0<span style=3D"white-space:pre-wrap;color:rgb(128,0,128)">E</span=
><span style=3D"white-space:pre-wrap;color:rgb(0,0,0)">::</span><span style=
=3D"white-space:pre-wrap">e0</span>, but this burden is largely outweigh by=
 the benefits of=C2=A0avoiding ambiguity and providing type safety, plus th=
e code is clearer. Giving a way to pull the enumerators out of the scope en=
tirely to me seems to defy the purpose of the scoped enums and would introd=
uce ambiguous cases. Consider the example below:<br><div><br></div><div>
<pre style=3D"margin-top:0px;margin-bottom:0px"><span style=3D"color:rgb(12=
8,128,0)">namespace</span><span style=3D"color:rgb(192,192,192)"> </span><s=
pan style=3D"color:rgb(128,0,128)">A</span><span style=3D"color:rgb(192,192=
,192)"> </span><span style=3D"color:rgb(0,0,0)">{</span></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px"><span style=3D"color:rgb(19=
2,192,192)">  </span><span style=3D"color:rgb(128,128,0)">namespace</span><=
span style=3D"color:rgb(192,192,192)"> </span><span style=3D"color:rgb(128,=
0,128)">B</span><span style=3D"color:rgb(192,192,192)"> </span><span style=
=3D"color:rgb(0,0,0)">{</span></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px"><span style=3D"color:rgb(19=
2,192,192)">    </span><span style=3D"color:rgb(128,128,0)">struct</span><s=
pan style=3D"color:rgb(192,192,192)"> </span><span style=3D"color:rgb(128,0=
,128)">X</span><span style=3D"color:rgb(192,192,192)"> </span><span style=
=3D"color:rgb(0,0,0)">{</span></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px"><span style=3D"color:rgb(19=
2,192,192)">      </span><span style=3D"color:rgb(128,128,0)">struct</span>=
<span style=3D"color:rgb(192,192,192)"> </span><span style=3D"color:rgb(128=
,0,128)">Y</span><span style=3D"color:rgb(192,192,192)"> </span><span style=
=3D"color:rgb(0,0,0)">{</span></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px"><span style=3D"color:rgb(19=
2,192,192)">        </span><span style=3D"color:rgb(128,128,0)">enum</span>=
<span style=3D"color:rgb(192,192,192)"> </span><span style=3D"color:rgb(128=
,128,0)">struct</span><span style=3D"color:rgb(192,192,192)"> </span><span =
style=3D"color:rgb(128,0,128)">E</span><span style=3D"color:rgb(192,192,192=
)"> </span><span style=3D"color:rgb(0,0,0)">:</span><span style=3D"color:rg=
b(192,192,192)"> </span><span style=3D"color:rgb(128,128,0)">int</span><spa=
n style=3D"color:rgb(192,192,192)"> </span><span style=3D"color:rgb(0,0,0)"=
>{</span></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px"><span style=3D"color:rgb(19=
2,192,192)">          </span><span style=3D"color:rgb(128,0,128)">e0</span>=
<span style=3D"color:rgb(192,192,192)"> </span><span style=3D"color:rgb(0,0=
,0)">=3D</span><span style=3D"color:rgb(192,192,192)"> </span><span style=
=3D"color:rgb(0,0,128)">1</span><span style=3D"color:rgb(0,0,0)">,</span><s=
pan style=3D"color:rgb(192,192,192)"> </span><span style=3D"color:rgb(128,0=
,128)">e1</span><span style=3D"color:rgb(0,0,0)">,</span><span style=3D"col=
or:rgb(192,192,192)"> </span><span style=3D"color:rgb(128,0,128)">e2</span>=
<span style=3D"color:rgb(0,0,0)">,</span></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px"><span style=3D"color:rgb(19=
2,192,192)">        </span><span style=3D"color:rgb(0,0,0)">};</span></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px"><span style=3D"color:rgb(19=
2,192,192)">      </span><span style=3D"color:rgb(0,0,0)">};</span></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px"><span style=3D"color:rgb(19=
2,192,192)">    </span><span style=3D"color:rgb(0,0,0)">};</span></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px"><span style=3D"color:rgb(19=
2,192,192)">  </span><span style=3D"color:rgb(0,0,0)">}</span></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px"><span style=3D"color:rgb(0,=
0,0)">}</span></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px"><br></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px"><span style=3D"color:rgb(12=
8,128,0)">int</span><span style=3D"color:rgb(192,192,192)"> </span><span st=
yle=3D"color:rgb(0,0,0)">main</span><span style=3D"color:rgb(0,0,0)">()</sp=
an><span style=3D"color:rgb(192,192,192)"> </span><span style=3D"color:rgb(=
0,0,0)">{</span></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px"><span style=3D"color:rgb(19=
2,192,192)">  </span><span style=3D"color:rgb(128,128,0)">using</span><span=
 style=3D"color:rgb(192,192,192)"> </span><span style=3D"color:rgb(128,0,12=
8)">E</span><span style=3D"color:rgb(192,192,192)"> </span><span style=3D"c=
olor:rgb(0,0,0)">=3D</span><span style=3D"color:rgb(192,192,192)"> </span><=
span style=3D"color:rgb(128,0,128)">A</span><span style=3D"color:rgb(0,0,0)=
">::</span><span style=3D"color:rgb(128,0,128)">B</span><span style=3D"colo=
r:rgb(0,0,0)">::</span><span style=3D"color:rgb(128,0,128)">X</span><span s=
tyle=3D"color:rgb(0,0,0)">::</span><span style=3D"color:rgb(128,0,128)">Y</=
span><span style=3D"color:rgb(0,0,0)">::</span><span style=3D"color:rgb(128=
,0,128)">E</span><span style=3D"color:rgb(0,0,0)">;</span></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px"><span style=3D"color:rgb(19=
2,192,192)">  </span><span style=3D"color:rgb(128,0,128)">A</span><span sty=
le=3D"color:rgb(0,0,0)">::</span><span style=3D"color:rgb(128,0,128)">B</sp=
an><span style=3D"color:rgb(0,0,0)">::</span><span style=3D"color:rgb(128,0=
,128)">X</span><span style=3D"color:rgb(0,0,0)">::</span><span style=3D"col=
or:rgb(128,0,128)">Y</span><span style=3D"color:rgb(0,0,0)">::</span><span =
style=3D"color:rgb(128,0,128)">E</span><span style=3D"color:rgb(192,192,192=
)"> </span><span style=3D"color:rgb(0,0,0)">var</span><span style=3D"color:=
rgb(192,192,192)"> </span><span style=3D"color:rgb(0,0,0)">=3D</span><span =
style=3D"color:rgb(192,192,192)"> </span><span style=3D"color:rgb(128,0,128=
)">E</span><span style=3D"color:rgb(0,0,0)">::</span><span style=3D"color:r=
gb(128,0,128)">e0</span><span style=3D"color:rgb(0,0,0)">;</span></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px"><span style=3D"color:rgb(19=
2,192,192)">  </span></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px"><span style=3D"color:rgb(19=
2,192,192)">  </span><span style=3D"color:rgb(0,128,0)">//</span><span styl=
e=3D"color:rgb(192,192,192)"> </span><span style=3D"color:rgb(0,128,0)">Thi=
s</span><span style=3D"color:rgb(192,192,192)"> </span><span style=3D"color=
:rgb(0,128,0)">should</span><span style=3D"color:rgb(192,192,192)"> </span>=
<span style=3D"color:rgb(0,128,0)">be</span><span style=3D"color:rgb(192,19=
2,192)"> </span><span style=3D"color:rgb(0,128,0)">legal</span><span style=
=3D"color:rgb(192,192,192)"> </span><span style=3D"color:rgb(0,128,0)">with=
</span><span style=3D"color:rgb(192,192,192)"> </span><span style=3D"color:=
rgb(0,128,0)">the</span><span style=3D"color:rgb(192,192,192)"> </span><spa=
n style=3D"color:rgb(0,128,0)">suggested</span><span style=3D"color:rgb(192=
,192,192)"> </span><span style=3D"color:rgb(0,128,0)">resolution</span></pr=
e>
<pre style=3D"margin-top:0px;margin-bottom:0px"><span style=3D"color:rgb(19=
2,192,192)">  </span><span style=3D"color:rgb(128,128,0)">using</span><span=
 style=3D"color:rgb(192,192,192)"> </span><span style=3D"color:rgb(128,128,=
0)">namespace</span><span style=3D"color:rgb(192,192,192)"> </span><span st=
yle=3D"color:rgb(128,0,128)">A</span><span style=3D"color:rgb(0,0,0)">::</s=
pan><span style=3D"color:rgb(128,0,128)">B</span><span style=3D"color:rgb(0=
,0,0)">::</span><span style=3D"color:rgb(128,0,128)">X</span><span style=3D=
"color:rgb(0,0,0)">::</span><span style=3D"color:rgb(128,0,128)">Y</span><s=
pan style=3D"color:rgb(0,0,0)">::</span><span style=3D"color:rgb(128,0,128)=
">E</span><span style=3D"color:rgb(0,0,0)">;</span></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px"><span style=3D"color:rgb(19=
2,192,192)">  </span><span style=3D"color:rgb(128,128,0)">if</span><span st=
yle=3D"color:rgb(0,0,0)">(</span><span style=3D"color:rgb(0,0,0)">var</span=
><span style=3D"color:rgb(192,192,192)"> </span><span style=3D"color:rgb(0,=
0,0)">=3D=3D</span><span style=3D"color:rgb(192,192,192)"> </span>e0<span s=
tyle=3D"color:rgb(0,0,0)">){}</span></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px"><span style=3D"color:rgb(19=
2,192,192)">  </span><span style=3D"color:rgb(128,128,0)">if</span><span st=
yle=3D"color:rgb(0,0,0)">((</span><span style=3D"color:rgb(128,128,0)">int<=
/span><span style=3D"color:rgb(0,0,0)">)</span><span style=3D"color:rgb(0,0=
,0)">var</span><span style=3D"color:rgb(192,192,192)"> </span><span style=
=3D"color:rgb(0,0,0)">=3D=3D</span><span style=3D"color:rgb(192,192,192)"> =
</span><span style=3D"color:rgb(0,0,0)">(</span><span style=3D"color:rgb(12=
8,128,0)">int</span><span style=3D"color:rgb(0,0,0)">)</span>e0<span style=
=3D"color:rgb(0,0,0)">){}</span><span style=3D"color:rgb(192,192,192)"> </s=
pan><span style=3D"color:rgb(0,128,0)">//</span><span style=3D"color:rgb(19=
2,192,192)"> </span><span style=3D"color:rgb(0,128,0)">then</span><span sty=
le=3D"color:rgb(192,192,192)"> </span><span style=3D"color:rgb(0,128,0)">so=
</span><span style=3D"color:rgb(192,192,192)"> </span><span style=3D"color:=
rgb(0,128,0)">is</span><span style=3D"color:rgb(192,192,192)"> </span><span=
 style=3D"color:rgb(0,128,0)">this</span></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px"><span style=3D"color:rgb(19=
2,192,192)">  </span></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px"><span style=3D"color:rgb(19=
2,192,192)">  </span><span style=3D"color:rgb(128,128,0)">int</span><span s=
tyle=3D"color:rgb(192,192,192)"> </span><span style=3D"color:rgb(0,0,0)">e0=
</span><span style=3D"color:rgb(192,192,192)"> </span><span style=3D"color:=
rgb(0,0,0)">=3D</span><span style=3D"color:rgb(192,192,192)"> </span><span =
style=3D"color:rgb(0,0,128)">123</span><span style=3D"color:rgb(0,0,0)">;</=
span><span style=3D"color:rgb(192,192,192)"> </span><span style=3D"color:rg=
b(0,128,0)">//</span><span style=3D"color:rgb(192,192,192)"> </span><span s=
tyle=3D"color:rgb(0,128,0)">introducing</span><span style=3D"color:rgb(192,=
192,192)"> </span><span style=3D"color:rgb(0,128,0)">an</span><span style=
=3D"color:rgb(192,192,192)"> </span><span style=3D"color:rgb(0,128,0)">int<=
/span><span style=3D"color:rgb(192,192,192)"> </span><span style=3D"color:r=
gb(0,128,0)">with</span><span style=3D"color:rgb(192,192,192)"> </span><spa=
n style=3D"color:rgb(0,128,0)">the</span><span style=3D"color:rgb(192,192,1=
92)"> </span><span style=3D"color:rgb(0,128,0)">same</span><span style=3D"c=
olor:rgb(192,192,192)"> </span><span style=3D"color:rgb(0,128,0)">identifie=
r</span></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px"><br></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px"><span style=3D"color:rgb(19=
2,192,192)">  </span><span style=3D"color:rgb(0,128,0)">//</span><span styl=
e=3D"color:rgb(192,192,192)"> </span><span style=3D"color:rgb(0,128,0)">cur=
rent</span><span style=3D"color:rgb(192,192,192)"> </span><span style=3D"co=
lor:rgb(0,128,0)">unambiguous</span><span style=3D"color:rgb(192,192,192)">=
 </span><span style=3D"color:rgb(0,128,0)">notation</span></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px"><span style=3D"color:rgb(19=
2,192,192)">  </span><span style=3D"color:rgb(128,128,0)">if</span><span st=
yle=3D"color:rgb(0,0,0)">((</span><span style=3D"color:rgb(128,128,0)">int<=
/span><span style=3D"color:rgb(0,0,0)">)</span><span style=3D"color:rgb(0,0=
,0)">var</span><span style=3D"color:rgb(192,192,192)"> </span><span style=
=3D"color:rgb(0,0,0)">=3D=3D</span><span style=3D"color:rgb(192,192,192)"> =
</span><span style=3D"color:rgb(0,0,0)">(</span><span style=3D"color:rgb(12=
8,128,0)">int</span><span style=3D"color:rgb(0,0,0)">)</span><span style=3D=
"color:rgb(128,128,0)">decltype</span><span style=3D"color:rgb(0,0,0)">(</s=
pan><span style=3D"color:rgb(0,0,0)">var</span><span style=3D"color:rgb(0,0=
,0)">)::</span>e0<span style=3D"color:rgb(0,0,0)">){}</span><span style=3D"=
color:rgb(192,192,192)"> </span><span style=3D"color:rgb(0,128,0)">//</span=
><span style=3D"color:rgb(192,192,192)"> </span><span style=3D"color:rgb(0,=
128,0)">ok:</span><span style=3D"color:rgb(192,192,192)"> </span><span styl=
e=3D"color:rgb(0,128,0)">if</span><span style=3D"color:rgb(192,192,192)"> <=
/span><span style=3D"color:rgb(0,128,0)">var</span><span style=3D"color:rgb=
(192,192,192)"> </span><span style=3D"color:rgb(0,128,0)">=3D=3D</span><spa=
n style=3D"color:rgb(192,192,192)"> </span><span style=3D"color:rgb(0,128,0=
)">1</span></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px"><span style=3D"color:rgb(19=
2,192,192)">  </span><span style=3D"color:rgb(128,128,0)">if</span><span st=
yle=3D"color:rgb(0,0,0)">((</span><span style=3D"color:rgb(128,128,0)">int<=
/span><span style=3D"color:rgb(0,0,0)">)</span><span style=3D"color:rgb(0,0=
,0)">var</span><span style=3D"color:rgb(192,192,192)"> </span><span style=
=3D"color:rgb(0,0,0)">=3D=3D</span><span style=3D"color:rgb(192,192,192)"> =
</span><span style=3D"color:rgb(0,0,0)">(</span><span style=3D"color:rgb(12=
8,128,0)">int</span><span style=3D"color:rgb(0,0,0)">)</span><span style=3D=
"color:rgb(128,0,128)">E</span><span style=3D"color:rgb(0,0,0)">::</span><s=
pan style=3D"color:rgb(128,0,128)">e0</span><span style=3D"color:rgb(0,0,0)=
">){}</span><span style=3D"color:rgb(192,192,192)"> </span><span style=3D"c=
olor:rgb(0,128,0)">//</span><span style=3D"color:rgb(192,192,192)"> </span>=
<span style=3D"color:rgb(0,128,0)">ok:</span><span style=3D"color:rgb(192,1=
92,192)"> </span><span style=3D"color:rgb(0,128,0)">if</span><span style=3D=
"color:rgb(192,192,192)"> </span><span style=3D"color:rgb(0,128,0)">var</sp=
an><span style=3D"color:rgb(192,192,192)"> </span><span style=3D"color:rgb(=
0,128,0)">=3D=3D</span><span style=3D"color:rgb(192,192,192)"> </span><span=
 style=3D"color:rgb(0,128,0)">1</span></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px"><span style=3D"color:rgb(19=
2,192,192)">  </span><span style=3D"color:rgb(128,128,0)">if</span><span st=
yle=3D"color:rgb(0,0,0)">((</span><span style=3D"color:rgb(128,128,0)">int<=
/span><span style=3D"color:rgb(0,0,0)">)</span><span style=3D"color:rgb(0,0=
,0)">var</span><span style=3D"color:rgb(192,192,192)"> </span><span style=
=3D"color:rgb(0,0,0)">=3D=3D</span><span style=3D"color:rgb(192,192,192)"> =
</span><span style=3D"color:rgb(0,0,0)">e0</span><span style=3D"color:rgb(0=
,0,0)">){}</span><span style=3D"color:rgb(192,192,192)"> </span><span style=
=3D"color:rgb(0,128,0)">//</span><span style=3D"color:rgb(192,192,192)"> </=
span><span style=3D"color:rgb(0,128,0)">ok:</span><span style=3D"color:rgb(=
192,192,192)"> </span><span style=3D"color:rgb(0,128,0)">if</span><span sty=
le=3D"color:rgb(192,192,192)"> </span><span style=3D"color:rgb(0,128,0)">va=
r</span><span style=3D"color:rgb(192,192,192)"> </span><span style=3D"color=
:rgb(0,128,0)">=3D=3D</span><span style=3D"color:rgb(192,192,192)"> </span>=
<span style=3D"color:rgb(0,128,0)">123</span></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px"><br></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px"><span style=3D"color:rgb(19=
2,192,192)">  </span><span style=3D"color:rgb(0,128,0)">//</span><span styl=
e=3D"color:rgb(192,192,192)"> </span><span style=3D"color:rgb(0,128,0)">sug=
gested</span><span style=3D"color:rgb(192,192,192)"> </span><span style=3D"=
color:rgb(0,128,0)">notation</span><span style=3D"color:rgb(192,192,192)"> =
</span><span style=3D"color:rgb(0,128,0)">ambiguities</span></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px"><span style=3D"color:rgb(19=
2,192,192)">  </span><span style=3D"color:rgb(128,128,0)">if</span><span st=
yle=3D"color:rgb(0,0,0)">((</span><span style=3D"color:rgb(128,128,0)">int<=
/span><span style=3D"color:rgb(0,0,0)">)</span><span style=3D"color:rgb(0,0=
,0)">var</span><span style=3D"color:rgb(192,192,192)"> </span><span style=
=3D"color:rgb(0,0,0)">=3D=3D</span><span style=3D"color:rgb(192,192,192)"> =
</span><span style=3D"color:rgb(0,0,0)">(</span><span style=3D"color:rgb(12=
8,128,0)">int</span><span style=3D"color:rgb(0,0,0)">)</span><span style=3D=
"color:rgb(0,0,0)">e0</span><span style=3D"color:rgb(0,0,0)">){}</span><spa=
n style=3D"color:rgb(192,192,192)"> </span><span style=3D"color:rgb(0,128,0=
)">//</span><span style=3D"color:rgb(192,192,192)"> </span><span style=3D"c=
olor:rgb(0,128,0)">??</span></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px"><span style=3D"color:rgb(19=
2,192,192)">  </span><span style=3D"color:rgb(128,128,0)">if</span><span st=
yle=3D"color:rgb(0,0,0)">((</span><span style=3D"color:rgb(128,128,0)">int<=
/span><span style=3D"color:rgb(0,0,0)">)</span><span style=3D"color:rgb(0,0=
,0)">e0</span><span style=3D"color:rgb(192,192,192)"> </span><span style=3D=
"color:rgb(0,0,0)">=3D=3D</span><span style=3D"color:rgb(192,192,192)"> </s=
pan><span style=3D"color:rgb(0,0,0)">(</span><span style=3D"color:rgb(128,1=
28,0)">int</span><span style=3D"color:rgb(0,0,0)">)</span><span style=3D"co=
lor:rgb(0,0,0)">var</span><span style=3D"color:rgb(0,0,0)">){}</span><span =
style=3D"color:rgb(192,192,192)"> </span><span style=3D"color:rgb(0,128,0)"=
>//</span><span style=3D"color:rgb(192,192,192)"> </span><span style=3D"col=
or:rgb(0,128,0)">??</span></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px"><br></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px"><span style=3D"color:rgb(19=
2,192,192)">  </span><span style=3D"color:rgb(128,128,0)">switch</span><spa=
n style=3D"color:rgb(0,0,0)">(</span><span style=3D"color:rgb(0,0,0)">var</=
span><span style=3D"color:rgb(0,0,0)">)</span><span style=3D"color:rgb(192,=
192,192)"> </span><span style=3D"color:rgb(0,0,0)">{</span><span style=3D"c=
olor:rgb(192,192,192)"> </span><span style=3D"color:rgb(128,128,0)">case</s=
pan><span style=3D"color:rgb(192,192,192)"> </span><span style=3D"color:rgb=
(0,0,0)">e0</span><span style=3D"color:rgb(0,0,0)">:</span><span style=3D"c=
olor:rgb(192,192,192)"> </span><span style=3D"color:rgb(0,0,0)">;</span><sp=
an style=3D"color:rgb(192,192,192)"> </span><span style=3D"color:rgb(0,0,0)=
">}</span></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px"><span style=3D"color:rgb(19=
2,192,192)">  </span><span style=3D"color:rgb(128,128,0)">switch</span><spa=
n style=3D"color:rgb(0,0,0)">((</span><span style=3D"color:rgb(128,128,0)">=
int</span><span style=3D"color:rgb(0,0,0)">)</span><span style=3D"color:rgb=
(0,0,0)">var</span><span style=3D"color:rgb(0,0,0)">)</span><span style=3D"=
color:rgb(192,192,192)"> </span><span style=3D"color:rgb(0,0,0)">{</span><s=
pan style=3D"color:rgb(192,192,192)"> </span><span style=3D"color:rgb(128,1=
28,0)">case</span><span style=3D"color:rgb(192,192,192)"> </span><span styl=
e=3D"color:rgb(0,0,0)">e0</span><span style=3D"color:rgb(0,0,0)">:</span><s=
pan style=3D"color:rgb(192,192,192)"> </span><span style=3D"color:rgb(0,0,0=
)">;</span><span style=3D"color:rgb(192,192,192)"> </span><span style=3D"co=
lor:rgb(0,0,0)">}</span><span style=3D"color:rgb(192,192,192)"> </span><spa=
n style=3D"color:rgb(0,128,0)">//</span><span style=3D"color:rgb(192,192,19=
2)"> </span><span style=3D"color:rgb(0,128,0)">??</span></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px"><span style=3D"color:rgb(19=
2,192,192)">  </span><span style=3D"color:rgb(128,128,0)">switch</span><spa=
n style=3D"color:rgb(0,0,0)">((</span><span style=3D"color:rgb(128,128,0)">=
int</span><span style=3D"color:rgb(0,0,0)">)</span><span style=3D"color:rgb=
(0,0,0)">var</span><span style=3D"color:rgb(0,0,0)">)</span><span style=3D"=
color:rgb(192,192,192)"> </span><span style=3D"color:rgb(0,0,0)">{</span><s=
pan style=3D"color:rgb(192,192,192)"> </span><span style=3D"color:rgb(128,1=
28,0)">case</span><span style=3D"color:rgb(192,192,192)"> </span><span styl=
e=3D"color:rgb(0,0,0)">(</span><span style=3D"color:rgb(128,128,0)">int</sp=
an><span style=3D"color:rgb(0,0,0)">)</span><span style=3D"color:rgb(0,0,0)=
">e0</span><span style=3D"color:rgb(0,0,0)">:</span><span style=3D"color:rg=
b(192,192,192)"> </span><span style=3D"color:rgb(0,0,0)">;</span><span styl=
e=3D"color:rgb(192,192,192)"> </span><span style=3D"color:rgb(0,0,0)">}</sp=
an><span style=3D"color:rgb(192,192,192)"> </span><span style=3D"color:rgb(=
0,128,0)">//</span><span style=3D"color:rgb(192,192,192)"> </span><span sty=
le=3D"color:rgb(0,128,0)">??</span></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px"><span style=3D"color:rgb(0,=
0,0)">}</span></pre></div><div><pre style=3D"margin-top:0px;margin-bottom:0=
px"></pre></div><div><br></div><div>This could get sorted by prioritizing o=
ne lookup over the other, but I don&#39;t see any universal way of doing th=
is; a resolution ordering that seems logical to some might not be to others=
.. In any case it makes the code more fragile since it would allow either a =
variable to shadow a scoped enumerator or a scoped enumerator to shadow a v=
ariable.</div></div><div class=3D"gmail_extra"><br><div class=3D"gmail_quot=
e">On Wed, Oct 29, 2014 at 6:35 AM, Jens Maurer <span dir=3D"ltr">&lt;<a hr=
ef=3D"mailto:Jens.Maurer@gmx.net" target=3D"_blank">Jens.Maurer@gmx.net</a>=
&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0=
 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=3D"">On 10=
/28/2014 11:02 PM, <a href=3D"mailto:corentin.schreiber@cea.fr">corentin.sc=
hreiber@cea.fr</a> wrote:<br>
&gt; As for being a major language change Thiago, I do not understand why y=
ou say so (nor do I know the consequences it implies).<br>
<br>
</span>There is no formal classification for something being a &quot;major =
change&quot;.<br>
<br>
However, properly specifying what you want to achieve, including<br>
its interactions with overload resolution and overloaded operators,<br>
seems like no small task.=C2=A0 I doubt the invested effort (including<br>
review effort within WG21) is worth the return.<br>
<br>
I can be convinced otherwise; please show me reasonably solid core<br>
language wording (as a change to the current standard/working draft)<br>
that implements your proposal.<br>
<br>
Thanks,<br>
Jens<br>
<div class=3D"HOEnZb"><div class=3D"h5"><br>
--<br>
<br>
---<br>
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals%2Bunsubscribe@isocpp.org">std-propo=
sals+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
</div></div></blockquote></div><br><br clear=3D"all"><div><br></div>-- <br>=
Thibaut LUTZ
</div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

--001a11402fbcd6cfff05068cd069--

.


Author: Matthew Woehlke <mw_triad@users.sourceforge.net>
Date: Wed, 29 Oct 2014 11:05:56 -0400
Raw View
On 2014-10-28 16:39, Myriachan wrote:
> I previously wanted to propose a "using namespace" extension, where you
> could specify a class name or enum name rather than just namespaces, but
> this thread looks like a similar topic, so I'll mention what I was going to
> propose.

I also desperately want this, at least for enums. Note for me though
that what I want to write is more like:

  namespace zoo
  {
    enum class animal
    {
      monkey,
      tiger,
      elephant
    };
    using enum animal;
  }

....and elsewhere:

  auto a = zoo::monkey; // okay; animal values in 'zoo' scope

That is, I want to be able to promote the values of a strongly typed
enum into a class or namespace scope (i.e. this would be in a header!).
I find that the additional scoping causes me to not want to use strongly
typed enums in many or even most cases. IMHO the feature is broken for
this reason.

Discussed elsewhere, but FWIW my inclination (as seen above) is toward
'using namespace/class/enum' rather than 'using namespace' for all
three. (But I'd happily take 'using namespace Enum' over not having the
feature at all.)

Keep in mind that you should probably specify that this is transitive,
i.e. given the above, 'using namespace zoo' should also bring the values
of 'animal' into the current scope. (You probably already know/expect
this, I'm mostly pointing out that it should probably be explicitly
mentioned in an official proposal.)

--
Matthew

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

.


Author: Matthew Woehlke <mw_triad@users.sourceforge.net>
Date: Wed, 29 Oct 2014 11:13:19 -0400
Raw View
On 2014-10-29 05:58, Thibaut Lutz wrote:
> At the risk of repeating myself, what is the advantage of using namespace A
> ::B::X::Y::E over using E = A::B::X::Y::E?

The first is only useful at a point of use. The second might be API
(i.e. some class definition wants to use a strongly typed enum, but
wants the user to be able to name the values as class members).

IMHO this is a *defect* in strongly typed enums; it *does not* always
make sense to restrict the enum values to an additional scope
(especially when they are already in some other scope). Personally, I
often do not use strongly typed enums for exactly this reason; because
the cost to the user of having to needlessly repeat an extra namespace
qualifier is considered unacceptable. In this sense, strongly typed
enums are broken compared to 'old style' enums. If we could fix this,
strongly typed enums would be much more useful.

Qt is a good case in point. Right now you can write e.g. Qt::AlignLeft,
Qt::white, Qt::TopLeftCorner, etc. All of these are different enums, but
they can be used without repeating the (often long) enum name. However,
they cannot be made into strongly typed enums because that would break
source compatibility and make them really awkward to use. (This is
particularly true of enums that live in classes, where having to type
both the class name *and enum name* is just gratuitous.)

--
Matthew

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

.


Author: Thibaut Lutz <thibaut.lutz@googlemail.com>
Date: Wed, 29 Oct 2014 09:45:11 -0700 (PDT)
Raw View
------=_Part_564_2127480749.1414601111276
Content-Type: text/plain; charset=UTF-8


>
> The first is only useful at a point of use.
>

They can both be used within a single scope, but one would injects the
enumerators in the namespace and the other still nicely encloses the enum
in a shorter named scope.


> IMHO this is a *defect* in strongly typed enums; it *does not* always
> make sense to restrict the enum values to an additional scope
> (especially when they are already in some other scope). Personally, I
> often do not use strongly typed enums for exactly this reason; because
> the cost to the user of having to needlessly repeat an extra namespace
> qualifier is considered unacceptable.
>

But isn't it the whole point of it though, that the scope must be explicit
at all times? It would be the same argument as saying one should use global
variables in a namespace instead of static class members, just because
their names can be injected at the point of use for convenience.

Qt is a good case in point. Right now you can write e.g. Qt::AlignLeft,
> Qt::white, Qt::TopLeftCorner, etc. All of these are different enums, but
> they can be used without repeating the (often long) enum name.


This is probably because you have grown accustomed to the interface as it
it, and because the interface was designed before this feature. Note that
the enums, and even the enumerators, have long and clunky names *because*
they didn't have scoped enums and they had to avoid name clashes somehow.
I personally think that having well named strongly typed enums which can
share otherwise conflicting enumerator names makes for much better code. To
take your Qt example, I think Qt::*Align*::*Left*, Qt::*Anchor*::*Left* and
Qt::*Elide*::*Left* would have made the code and the documentation a lot
nicer. It is a shame older interfaces cannot introduce this feature without
breaking code, yes, but I don't think it would make the interfaces awkward.

A similar discussion must have taken place a long time ago about pulling
old-style class scoped enums or static members out of the class scope using
a "using class ..." construct or similar, maybe it would be a good place to
find arguments for and against. I must say it still sounds like a bad idea
to me.

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

------=_Part_564_2127480749.1414601111276
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><blockquote class=3D"gmail_quote" style=3D"margin: 0;margi=
n-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">The first is =
only useful at a point of use. <br></blockquote><div><br></div><div>They ca=
n both be used within a single scope, but one would injects the enumerators=
 in the namespace and the other still nicely encloses the enum in a shorter=
 named scope.</div><div>&nbsp;</div><blockquote class=3D"gmail_quote" style=
=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: =
1ex;">IMHO this is a *defect* in strongly typed enums; it *does not* always
<br>make sense to restrict the enum values to an additional scope
<br>(especially when they are already in some other scope). Personally, I
<br>often do not use strongly typed enums for exactly this reason; because
<br>the cost to the user of having to needlessly repeat an extra namespace
<br>qualifier is considered unacceptable.<br></blockquote><div><br></div><d=
iv>But isn't it the whole point of it though, that the scope must be explic=
it at all times? It would be the same argument as saying one should use glo=
bal variables in a namespace instead of static class members, just because =
their names can be injected at the point of use for convenience.</div><div>=
<br></div><blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left:=
 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">Qt is a good case in=
 point. Right now you can write e.g. Qt::AlignLeft,
<br>Qt::white, Qt::TopLeftCorner, etc. All of these are different enums, bu=
t
<br>they can be used without repeating the (often long) enum name. </blockq=
uote><div><br></div><div>This is probably because you have grown&nbsp;accus=
tomed to the interface as it it, and because the interface was designed bef=
ore this feature. Note that the enums, and even the enumerators, have long =
and clunky names <i>because</i> they didn't have scoped enums and they had =
to avoid name clashes somehow.&nbsp;</div><div>I personally think that havi=
ng well named strongly typed enums which can share otherwise conflicting en=
umerator names makes for much better code. To take your Qt example, I think=
 Qt::<b>Align</b>::<i>Left</i>, Qt::<b>Anchor</b>::<i>Left</i> and Qt::<b>E=
lide</b>::<i>Left</i> would have made the code and the documentation a lot =
nicer. It is a shame older interfaces cannot introduce this feature without=
 breaking code, yes, but I don't think it would make the interfaces awkward=
..</div><div><br></div><div>A similar discussion must have taken place a lon=
g time ago about pulling old-style class scoped enums or static members out=
 of the class scope using a "using class ..." construct or similar, maybe i=
t would be a good place to find arguments for and against. I must say it st=
ill sounds like a bad idea to me.</div></div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_564_2127480749.1414601111276--

.


Author: Matthew Woehlke <mw_triad@users.sourceforge.net>
Date: Wed, 29 Oct 2014 13:58:33 -0400
Raw View
On 2014-10-29 12:45, Thibaut Lutz wrote:
>> The first is only useful at a point of use.
>
> They can both be used within a single scope, but one would injects the
> enumerators in the namespace and the other still nicely encloses the enum
> in a shorter named scope.

The second is completely useless to the use cases I care about. I want
the enum *values* in the same scope as the enum itself (i.e. old-style
enum). If a shorter name would solve the problem, I could just give the
enum a shorter name in the first place.

> But isn't it the whole point of it though, that the scope must be explicit
> at all times?

No. The point is to disallow implicit conversions. For maybe half of my
uses, requiring the scope is an anti-feature that results in me not
using strongly typed enums.

For *some* uses it may be a feature, and I don't have a problem with it
being the default behavior... as long as there is an opt-out mechanism.
That's what's missing (and what we're proposing to add).

>> Qt is a good case in point. Right now you can write e.g. Qt::AlignLeft,
>> Qt::white, Qt::TopLeftCorner, etc. All of these are different enums, but
>> they can be used without repeating the (often long) enum name.
>
> This is probably because you have grown accustomed to the interface as it
> it, and because the interface was designed before this feature.

No, it isn't. Consider QDialog::DialogCode. It makes perfect sense that
this enum should live inside of QDialog and not the global namespace. It
also makes perfect sense that I should refer to the values as e.g.
QDialog::Accepted. This is the optimal API design from a naming
standpoint. It works great with old-style enums, but cannot be done
easily with strongly typed enums, which is a real shame.

This is just one example. I can probably come up with a half dozen more
just offhand, and not only in Qt but in my own code as well.

If it was just a matter of "habit", I should be able to create brand new
API's without running into this problem. Alas, no such luck...

> I personally think that having well named strongly typed enums which can
> share otherwise conflicting enumerator names makes for much better code.

Oh, don't get me wrong; scoping of enum values *does* have uses. I just
shouldn't be "forced" into that scoping.

(Also... sometimes it's just better naming to repeat the enum name in
the value names, e.g. when 'ValueEnum' is much better than
'Enum::Value'. Especially if 'Value' not followed by 'Enum' is poor
grammar.)

> I must say it still sounds like a bad idea to me.

So don't use it. Many people think 'using namespace std' is Evil, but
the standard still allows it.

--
Matthew

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

.


Author: Myriachan <myriachan@gmail.com>
Date: Wed, 29 Oct 2014 13:23:51 -0700 (PDT)
Raw View
------=_Part_3_838650394.1414614231556
Content-Type: text/plain; charset=UTF-8

On Wednesday, October 29, 2014 10:58:52 AM UTC-7, Matthew Woehlke wrote:
>
> On 2014-10-29 12:45, Thibaut Lutz wrote:
> >> The first is only useful at a point of use.
> >
> > They can both be used within a single scope, but one would injects the
> > enumerators in the namespace and the other still nicely encloses the
> enum
> > in a shorter named scope.
>
> The second is completely useless to the use cases I care about. I want
> the enum *values* in the same scope as the enum itself (i.e. old-style
> enum). If a shorter name would solve the problem, I could just give the
> enum a shorter name in the first place.
>
> > But isn't it the whole point of it though, that the scope must be
> explicit
> > at all times?
>
> No. The point is to disallow implicit conversions. For maybe half of my
> uses, requiring the scope is an anti-feature that results in me not
> using strongly typed enums.
>
> For *some* uses it may be a feature, and I don't have a problem with it
> being the default behavior... as long as there is an opt-out mechanism.
> That's what's missing (and what we're proposing to add).
>
>
I agree with Matthew here.  The reason we don't use enum class in my
employer's codebase is because we can't migrate existing code to it.  We'd
have to add scope operators everywhere.  I understand why there is a
kinda-namespace added with enum class, but it would be really nice to be
able to optionally acquire the old scoping behavior using "using namespace"
or similar.

Allowing "using namespace" on classes would additionally be nice.  It
allows a bit of the functionality of "with" without the complexity of
"with".

I'm thinking of writing up a Standardese patch for "using namespace", but
if there is a lot of disagreement I won't bother =^-^=

Melissa

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

------=_Part_3_838650394.1414614231556
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On Wednesday, October 29, 2014 10:58:52 AM UTC-7, Matthew =
Woehlke wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-l=
eft: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">On 2014-10-29 12=
:45, Thibaut Lutz wrote:
<br>&gt;&gt; The first is only useful at a point of use.=20
<br>&gt;=20
<br>&gt; They can both be used within a single scope, but one would injects=
 the=20
<br>&gt; enumerators in the namespace and the other still nicely encloses t=
he enum=20
<br>&gt; in a shorter named scope.
<br>
<br>The second is completely useless to the use cases I care about. I want
<br>the enum *values* in the same scope as the enum itself (i.e. old-style
<br>enum). If a shorter name would solve the problem, I could just give the
<br>enum a shorter name in the first place.
<br>
<br>&gt; But isn't it the whole point of it though, that the scope must be =
explicit=20
<br>&gt; at all times?
<br>
<br>No. The point is to disallow implicit conversions. For maybe half of my
<br>uses, requiring the scope is an anti-feature that results in me not
<br>using strongly typed enums.
<br>
<br>For *some* uses it may be a feature, and I don't have a problem with it
<br>being the default behavior... as long as there is an opt-out mechanism.
<br>That's what's missing (and what we're proposing to add).
<br>
<br></blockquote><br>I agree with Matthew here.&nbsp; The reason we don't u=
se enum class in my employer's codebase is because we can't migrate existin=
g code to it.&nbsp; We'd have to add scope operators everywhere.&nbsp; I un=
derstand why there is a kinda-namespace added with enum class, but it would=
 be really nice to be able to optionally acquire the old scoping behavior u=
sing "using namespace" or similar.<br><br>Allowing "using namespace" on cla=
sses would additionally be nice.&nbsp; It allows a bit of the functionality=
 of "with" without the complexity of "with".<br><br>I'm thinking of writing=
 up a Standardese patch for "using namespace", but if there is a lot of dis=
agreement I won't bother =3D^-^=3D<br><br>Melissa<br></div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_3_838650394.1414614231556--

.


Author: Kenshi Takayama <kenshi84@gmail.com>
Date: Wed, 29 Oct 2014 20:03:50 -0700 (PDT)
Raw View
------=_Part_240_137886491.1414638230519
Content-Type: text/plain; charset=UTF-8

Thanks for your thorough feedback and opinions.

What I had in mind was indeed similar to ADL, but for resolving argument's
namespace.
My point was that since the scoped enum prohibits implicit conversions from
other types (unless conversion operators are otherwise user defined), there
shouldn't be so much of ambiguity problems.
If there exist such user-defined conversion operators, then those could be
prioritized over ADL.

I' try to explain my idea through a code:
struct X {
  enum struct E : int {
    e0 = 1, e1, e2
  };
};

void f() {
  X::E var = e0;                  // X::E var = X::E::e0;
  var = e0;                       // var = X::E::e0;
  if (var == e0) {}               // if (var == X::E::e0) {}

  // it'd be nice to maintain symmetry, but it's less important in my
opinion
  if (e0 == var) {}               // if (X::E::e0 == var) {}

  // after converting to a different type, the special lookup is disabled
  if ((int)var == e0) {}          // error: 'e0' is not found
  // so this shouldn't lead to ambiguity
  const int e0 = 123;
  if ((int)var == e0) {}          // if (1 == 123) {}
  if ((int)var == (int)e0) {}     // if (1 == 123) {}
  switch (var) {
    case e0: ;      // case X::E::e0: ;
  }
  switch ((int)var) {
    case e0: ;      // case 123: ;
    case e1: ;      // error: 'e1' is not found
  }

  // it'd also be nice if this is allowed for function args/return as well
  auto g = [](X::E arg = e0) -> X::E { return e0; };
  // auto g = [](X::E arg = X::E::e0) -> X::E { return X::E::e0; };

  g(e0);            // g(X::E::e0);
  g((int)e0);       // error: 'int' cannot be converted to 'X::E'
  // probably doesn't matter whether the compiler looks at local 'e0' or
'X::E::e0'
}

struct Y {
  operator X::E() const {
    return e0;    // return X::E::e0
  }
};

void h() {
  X::E var = e0;   // X::E var = X::E::e0;
  if (var == e0) {} // if (var == X::E::e0) {}

  // local variable named 'e0' which can be converted to X::E ==> this
match should be prioritized over the special lookup
  Y e0;
  if (var == e0) {} // if (var == e0) {}
}

Kenshi

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

------=_Part_240_137886491.1414638230519
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>Thanks for your thorough feedback and opinions.</div>=
<div><br></div>What I had in mind was indeed similar to ADL, but for resolv=
ing argument's namespace.<div>My point was that since the scoped enum prohi=
bits implicit conversions from other types (unless conversion operators are=
 otherwise user defined), there shouldn't be so much of ambiguity problems.=
</div><div>If there exist such user-defined conversion operators, then thos=
e could be prioritized over ADL.</div><div><br></div><div>I' try to explain=
 my idea through a code:</div><div><div class=3D"prettyprint" style=3D"bord=
er: 1px solid rgb(187, 187, 187); word-wrap: break-word; background-color: =
rgb(250, 250, 250);"><code class=3D"prettyprint"><div class=3D"subprettypri=
nt"><span style=3D"color: #008;" class=3D"styled-by-prettify">struct</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> X </span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"><br>&nbsp; </span><span style=3D"=
color: #008;" class=3D"styled-by-prettify">enum</span><span style=3D"color:=
 #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" c=
lass=3D"styled-by-prettify">struct</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> E </span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">:</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">i=
nt</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">{</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; e0 </spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify"> </span><font color=3D=
"#006666"><span style=3D"color: #066;" class=3D"styled-by-prettify">1</span=
></font><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> e1</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> e2<br>&nbsp; </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">};</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">};</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"><br><br></span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">void</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> f</span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">()</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; X</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">::</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify">E </span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">var</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> e0</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</sp=
an><span style=3D"color: #800;" class=3D"styled-by-prettify">// X::E var =
=3D X::E::e0;</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"><br>&nbsp; </span><span style=3D"color: #008;" class=3D"styled-by-pretti=
fy">var</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> e0</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;=
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style=3D"color: #80=
0;" class=3D"styled-by-prettify">// var =3D X::E::e0;</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"><br>&nbsp; </span><span style=3D=
"color: #008;" class=3D"styled-by-prettify">if</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">(</span><span style=3D"color: #008;" class=3D"st=
yled-by-prettify">var</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">=3D=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> e=
0</span><span style=3D"color: #660;" class=3D"styled-by-prettify">)</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">{}</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;=
 &nbsp; &nbsp; </span><span style=3D"color: #800;" class=3D"styled-by-prett=
ify">// if (var =3D=3D X::E::e0) {}</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"><br>&nbsp; <br>&nbsp; </span><span style=3D"color:=
 #800;" class=3D"styled-by-prettify">// it'd be nice to maintain symmetry, =
but it's less important in my opinion</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"><br>&nbsp; </span><span style=3D"color: #008;" c=
lass=3D"styled-by-prettify">if</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
">e0 </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D=
=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span style=3D"color: #008;" class=3D"styled-by-prettify">var</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">)</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">{}</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;=
 </span><span style=3D"color: #800;" class=3D"styled-by-prettify">// if (X:=
:E::e0 =3D=3D var) {}</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"><br>&nbsp; <br>&nbsp; </span><span style=3D"color: #800;" class=
=3D"styled-by-prettify">// after converting to a different type, the specia=
l lookup is disabled</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"><br>&nbsp; </span><span style=3D"color: #008;" class=3D"styled-by=
-prettify">if</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">((</sp=
an><span style=3D"color: #008;" class=3D"styled-by-prettify">int</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">)</span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">var</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">=3D=3D</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> e0</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">)</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">{}</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> &nbsp=
; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style=3D"color: #800;" class=3D"s=
tyled-by-prettify">// error: 'e0' is not found</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"><br>&nbsp; </span><span style=3D"color:=
 #800;" class=3D"styled-by-prettify">// so this shouldn't lead to ambiguity=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp;=
 </span><span style=3D"color: #008;" class=3D"styled-by-prettify">const</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span =
style=3D"color: #008;" class=3D"styled-by-prettify">int</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> e0 </span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> </span><span style=3D"color: #066;" clas=
s=3D"styled-by-prettify">123</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"><br>&nbsp; </span><span style=3D"color: #008;" class=3D"styled-by-=
prettify">if</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">((</spa=
n><span style=3D"color: #008;" class=3D"styled-by-prettify">int</span><span=
 style=3D"color: #660;" class=3D"styled-by-prettify">)</span><span style=3D=
"color: #008;" class=3D"styled-by-prettify">var</span><span style=3D"color:=
 #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">=3D=3D</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> e0</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">)</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">{=
}</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> &nbsp; &=
nbsp; &nbsp; &nbsp; &nbsp;</span><span style=3D"color: #800;" class=3D"styl=
ed-by-prettify">// if (1 =3D=3D 123) {}</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"><br>&nbsp; </span><span style=3D"color: #008;"=
 class=3D"styled-by-prettify">if</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">((</span><span style=3D"color: #008;" class=3D"styled-by-pre=
ttify">int</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
)</span><span style=3D"color: #008;" class=3D"styled-by-prettify">var</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">=3D=3D</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #008;" =
class=3D"styled-by-prettify">int</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">)</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify">e0</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">)</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> <=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">{}</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> &nbsp; &nbsp; </sp=
an><span style=3D"color: #800;" class=3D"styled-by-prettify">// if (1 =3D=
=3D 123) {}</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
><br>&nbsp; </span><span style=3D"color: #008;" class=3D"styled-by-prettify=
">switch</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> <=
/span><font color=3D"#000000"><span style=3D"color: #660;" class=3D"styled-=
by-prettify">(</span><span style=3D"color: #008;" class=3D"styled-by-pretti=
fy">var</span><span style=3D"color: #660;" class=3D"styled-by-prettify">)</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; </span><sp=
an style=3D"color: #008;" class=3D"styled-by-prettify">case</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"> e0</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">:</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> &nbsp; &nbsp; &nbsp;</span><span style=3D"color: #800;" cla=
ss=3D"styled-by-prettify">// case X::E::e0: ;</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"><br></span></font><span style=3D"color: =
#000;" class=3D"styled-by-prettify">&nbsp; </span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">}</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br>&nbsp; </span><span style=3D"color: #008;" clas=
s=3D"styled-by-prettify">switch</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">((</span><span style=3D"color: #008;" class=3D"styled-by-pretti=
fy">int</span><span style=3D"color: #660;" class=3D"styled-by-prettify">)</=
span><span style=3D"color: #008;" class=3D"styled-by-prettify">var</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">)</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">{</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"><br>&nbsp; &nbsp; </span><span style=3D"color:=
 #008;" class=3D"styled-by-prettify">case</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> e0</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">:</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> </span><font color=3D"#666600"><span style=3D"color: #660;"=
 class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"> &nbsp; &nbsp; &nbsp;</span><span style=3D"color: #800=
;" class=3D"styled-by-prettify">// case 123: ;</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"><br></span></font><span style=3D"color:=
 #000;" class=3D"styled-by-prettify">&nbsp; &nbsp; </span><span style=3D"co=
lor: #008;" class=3D"styled-by-prettify">case</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> e1</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">:</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> &nbsp; &nbsp; &nbsp;</span><span style=3D"color: #800;" class=3D"styled-b=
y-prettify">// error: 'e1' is not found</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"><br>&nbsp; </span><span style=3D"color: #660;"=
 class=3D"styled-by-prettify">}</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"><br>&nbsp; <br>&nbsp; </span><span style=3D"color: #80=
0;" class=3D"styled-by-prettify">// it'd also be nice if this is allowed fo=
r function args/return as well</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"><br>&nbsp; </span><span style=3D"color: #008;" class=3D=
"styled-by-prettify">auto</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> g </span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">[](</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify">X</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">::</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify">E arg </span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> e0</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">)</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">-&gt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> X</span><span style=3D"color: #660;" class=3D"styled-by-prettify">::</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify">E </span><span=
 style=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #=
008;" class=3D"styled-by-prettify">return</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> e0</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">};</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><b=
r>&nbsp; </span><span style=3D"color: #800;" class=3D"styled-by-prettify">/=
/ auto g =3D [](X::E arg =3D X::E::e0) -&gt; X::E { return X::E::e0; };</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; <br=
>&nbsp; g</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify">e0</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">)</span><font colo=
r=3D"#000000"><span style=3D"color: #660;" class=3D"styled-by-prettify">;</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> &nbsp; &nbs=
p; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style=3D"color: #800;" class=3D"=
styled-by-prettify">// g(X::E::e0);</span></font><span style=3D"color: #000=
;" class=3D"styled-by-prettify"><br>&nbsp; g</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">((</span><span style=3D"color: #008;" cla=
ss=3D"styled-by-prettify">int</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">)</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify">e0</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">)</span><font color=3D"#000000" style=3D"font-size: 13.1428575515747px;">=
<span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"> &nbsp; &nbsp; &nbsp; </sp=
an><span style=3D"color: #800;" class=3D"styled-by-prettify">// error: 'int=
' cannot be converted to 'X::E'</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"><br></span></font><span style=3D"color: #000;" class=
=3D"styled-by-prettify">&nbsp; </span><span style=3D"color: #800;" class=3D=
"styled-by-prettify">// probably doesn't matter whether the compiler looks =
at local 'e0' or 'X::E::e0'</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"><br></span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">}</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"><br><br></span><span style=3D"color: #008;" class=3D"styled-by-prettify">=
struct</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> Y <=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; </span><s=
pan style=3D"color: #008;" class=3D"styled-by-prettify">operator</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> X</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">::</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify">E</span><span style=3D"color: #660;"=
 class=3D"styled-by-prettify">()</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"style=
d-by-prettify">const</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>{</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbs=
p; &nbsp; </span><span style=3D"color: #008;" class=3D"styled-by-prettify">=
return</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> e0<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> &nbsp; &nbsp;</span=
><span style=3D"color: #800;" class=3D"styled-by-prettify">// return X::E::=
e0</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbs=
p; </span><span style=3D"color: #660;" class=3D"styled-by-prettify">}</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span=
 style=3D"color: #660;" class=3D"styled-by-prettify">};</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br><br></span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">void</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> h</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">()</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">{</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"><br>&nbsp; X</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">::</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
>E</span><font color=3D"#666600"><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-pre=
ttify">var</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
 </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> e0</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> &nbsp; </span><span style=3D"co=
lor: #800;" class=3D"styled-by-prettify">// X::E var =3D X::E::e0;</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"><br></span></font><=
span style=3D"color: #000;" class=3D"styled-by-prettify">&nbsp; </span><spa=
n style=3D"color: #008;" class=3D"styled-by-prettify">if</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #008;" =
class=3D"styled-by-prettify">var</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">=3D=3D</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> e0</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">)</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">{}</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D=
"color: #800;" class=3D"styled-by-prettify">// if (var =3D=3D X::E::e0) {}<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; =
<br>&nbsp; </span><span style=3D"color: #800;" class=3D"styled-by-prettify"=
>// local variable named 'e0' which can be converted to X::E =3D=3D&gt; thi=
s match should be prioritized over the special lookup</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"><br>&nbsp; Y e0</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"><br>&nbsp; </span><span style=3D"col=
or: #008;" class=3D"styled-by-prettify">if</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">(</span><span style=3D"color: #008;" class=3D"style=
d-by-prettify">var</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
=3D=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> e0<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">)</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">{}</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #800;"=
 class=3D"styled-by-prettify">// if (var =3D=3D e0) {}</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">}</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"><br></span></div></code></div><div><br></div><=
div>Kenshi</div><br></div></div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_240_137886491.1414638230519--

.


Author: =?UTF-8?Q?David_Rodr=C3=ADguez_Ibeas?= <dibeas@ieee.org>
Date: Thu, 30 Oct 2014 10:17:24 -0400
Raw View
--485b397dd2931730840506a48a35
Content-Type: text/plain; charset=UTF-8

Thibaut,

   The code you present would not lead to ambiguities for the compiler,
although it will surely be surprising for the programmer/maintainer. A
using directive (using namespace) does not (at least the current
incarnation) inject the names into the current scope, but makes them
available as if declared in a namespace scope, in the example you provide
to the global namespace (first common ancestor of 'main' and the used
namespace). So the local variable hides the name that would be found with
the 'using namespace'.

    This might or not be the intention of the suggested proposal. If it is,
then there is no ambiguity but there will be surprises (the same that we
currently have with using directives [1]). If it is not, then the suggested
proposal would have different behavior than the using directive has today
and will confuse everyone even more than we are today (I personally believe
that there cannot be much more than 10 people that really understand lookup
as specified in the language --and this includes compiler implementors).

    David

[1]: What does the following program output to the console?

namespace A { namespace B { const int x = 1; } }
namespace C {
    const int x = 2;
    namespace D {
        using namespace ::A::B;
    }
    namespace E {
        void f() {
            using namespace ::A::B;
            std::cout << x;
            std::cout << D::x;
        }
    }
}

Answer: 21


On Wed, Oct 29, 2014 at 5:58 AM, Thibaut Lutz <thibaut.lutz@googlemail.com>
wrote:

> At the risk of repeating myself, what is the advantage of using namespace
> A::B::X::Y::E over using E = A::B::X::Y::E? Sure in the latter one has to
> type three extra characters to use E::e0, but this burden is largely
> outweigh by the benefits of avoiding ambiguity and providing type safety,
> plus the code is clearer. Giving a way to pull the enumerators out of the
> scope entirely to me seems to defy the purpose of the scoped enums and
> would introduce ambiguous cases. Consider the example below:
>
> namespace A {
>
>   namespace B {
>
>     struct X {
>
>       struct Y {
>
>         enum struct E : int {
>
>           e0 = 1, e1, e2,
>
>         };
>
>       };
>
>     };
>
>   }
>
> }
>
>
> int main() {
>
>   using E = A::B::X::Y::E;
>
>   A::B::X::Y::E var = E::e0;
>
>     // This should be legal with the suggested resolution
>
>   using namespace A::B::X::Y::E;
>
>   if(var == e0){}
>
>   if((int)var == (int)e0){} // then so is this
>
>     int e0 = 123; // introducing an int with the same identifier
>
>
>   // current unambiguous notation
>
>   if((int)var == (int)decltype(var)::e0){} // ok: if var == 1
>
>   if((int)var == (int)E::e0){} // ok: if var == 1
>
>   if((int)var == e0){} // ok: if var == 123
>
>
>   // suggested notation ambiguities
>
>   if((int)var == (int)e0){} // ??
>
>   if((int)e0 == (int)var){} // ??
>
>
>   switch(var) { case e0: ; }
>
>   switch((int)var) { case e0: ; } // ??
>
>   switch((int)var) { case (int)e0: ; } // ??
>
> }
>
>
> This could get sorted by prioritizing one lookup over the other, but I
> don't see any universal way of doing this; a resolution ordering that seems
> logical to some might not be to others. In any case it makes the code more
> fragile since it would allow either a variable to shadow a scoped
> enumerator or a scoped enumerator to shadow a variable.
>
> On Wed, Oct 29, 2014 at 6:35 AM, Jens Maurer <Jens.Maurer@gmx.net> wrote:
>
>> On 10/28/2014 11:02 PM, corentin.schreiber@cea.fr wrote:
>> > As for being a major language change Thiago, I do not understand why
>> you say so (nor do I know the consequences it implies).
>>
>> There is no formal classification for something being a "major change".
>>
>> However, properly specifying what you want to achieve, including
>> its interactions with overload resolution and overloaded operators,
>> seems like no small task.  I doubt the invested effort (including
>> review effort within WG21) is worth the return.
>>
>> I can be convinced otherwise; please show me reasonably solid core
>> language wording (as a change to the current standard/working draft)
>> that implements your proposal.
>>
>> Thanks,
>> Jens
>>
>> --
>>
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "ISO C++ Standard - Future Proposals" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to std-proposals+unsubscribe@isocpp.org.
>> To post to this group, send email to std-proposals@isocpp.org.
>> Visit this group at
>> http://groups.google.com/a/isocpp.org/group/std-proposals/.
>>
>
>
>
> --
> Thibaut LUTZ
>
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "ISO C++ Standard - Future Proposals" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to std-proposals+unsubscribe@isocpp.org.
> To post to this group, send email to std-proposals@isocpp.org.
> Visit this group at
> http://groups.google.com/a/isocpp.org/group/std-proposals/.
>

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

--485b397dd2931730840506a48a35
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Thibaut,<div><br>=C2=A0 =C2=A0The code you present would n=
ot lead to ambiguities for the compiler, although it will surely be surpris=
ing for the programmer/maintainer. A using directive (using namespace) does=
 not (at least the current incarnation) inject the names into the current s=
cope, but makes them available as if declared in a namespace scope, in the =
example you provide to the global namespace (first common ancestor of &#39;=
main&#39; and the used namespace). So the local variable hides the name tha=
t would be found with the &#39;using namespace&#39;.<br><br>=C2=A0 =C2=A0 T=
his might or not be the intention of the suggested proposal. If it is, then=
 there is no ambiguity but there will be surprises (the same that we curren=
tly have with using directives [1]). If it is not, then the suggested propo=
sal would have different behavior than the using directive has today and wi=
ll confuse everyone even more than we are today (I personally believe that =
there cannot be much more than 10 people that really understand lookup as s=
pecified in the language --and this includes compiler implementors).<br><br=
>=C2=A0 =C2=A0 David<br><br>[1]: What does the following program output to =
the console?<br><br>namespace A { namespace B { const int x =3D 1; } }<br>n=
amespace C {<br>=C2=A0 =C2=A0 const int x =3D 2;<br>=C2=A0 =C2=A0 namespace=
 D {<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 using namespace ::A::B;</div><div>=C2=
=A0 =C2=A0 }<br>=C2=A0 =C2=A0 namespace E {<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =
void f() { <br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 using namespace ::=
A::B; <br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 std::cout &lt;&lt; x;<b=
r>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 std::cout &lt;&lt; D::x;<br>=C2=
=A0 =C2=A0 =C2=A0 =C2=A0 }<br>=C2=A0 =C2=A0 }<br>}<br><br>Answer: 21<br><br=
></div></div><div class=3D"gmail_extra"><br><div class=3D"gmail_quote">On W=
ed, Oct 29, 2014 at 5:58 AM, Thibaut Lutz <span dir=3D"ltr">&lt;<a href=3D"=
mailto:thibaut.lutz@googlemail.com" target=3D"_blank">thibaut.lutz@googlema=
il.com</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"=
margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"=
ltr">At the risk of repeating myself, what is the advantage of=C2=A0<span s=
tyle=3D"color:rgb(128,128,0)">using</span><span style=3D"color:rgb(192,192,=
192)"> </span><span style=3D"color:rgb(128,128,0)">namespace</span><span st=
yle=3D"color:rgb(192,192,192)"> </span><span style=3D"color:rgb(128,0,128)"=
>A</span><span style=3D"color:rgb(0,0,0)">::</span><span style=3D"color:rgb=
(128,0,128)">B</span><span style=3D"color:rgb(0,0,0)">::</span><span style=
=3D"color:rgb(128,0,128)">X</span><span style=3D"color:rgb(0,0,0)">::</span=
><span style=3D"color:rgb(128,0,128)">Y</span><span style=3D"color:rgb(0,0,=
0)">::</span><span style=3D"color:rgb(128,0,128)">E</span>=C2=A0over=C2=A0<=
span style=3D"color:rgb(128,128,0)">using</span><span style=3D"color:rgb(19=
2,192,192)"> </span><span style=3D"color:rgb(128,0,128)">E</span><span styl=
e=3D"color:rgb(192,192,192)"> </span><span style=3D"color:rgb(0,0,0)">=3D</=
span><span style=3D"color:rgb(192,192,192)"> </span><span style=3D"color:rg=
b(128,0,128)">A</span><span style=3D"color:rgb(0,0,0)">::</span><span style=
=3D"color:rgb(128,0,128)">B</span><span style=3D"color:rgb(0,0,0)">::</span=
><span style=3D"color:rgb(128,0,128)">X</span><span style=3D"color:rgb(0,0,=
0)">::</span><span style=3D"color:rgb(128,0,128)">Y</span><span style=3D"co=
lor:rgb(0,0,0)">::</span><span style=3D"color:rgb(128,0,128)">E</span>? Sur=
e in the latter one has to type three extra characters to use=C2=A0<span st=
yle=3D"white-space:pre-wrap;color:rgb(128,0,128)">E</span><span style=3D"wh=
ite-space:pre-wrap;color:rgb(0,0,0)">::</span><span style=3D"white-space:pr=
e-wrap">e0</span>, but this burden is largely outweigh by the benefits of=
=C2=A0avoiding ambiguity and providing type safety, plus the code is cleare=
r. Giving a way to pull the enumerators out of the scope entirely to me see=
ms to defy the purpose of the scoped enums and would introduce ambiguous ca=
ses. Consider the example below:<br><div><br></div><div><span class=3D"">
<pre style=3D"margin-top:0px;margin-bottom:0px"><span style=3D"color:rgb(12=
8,128,0)">namespace</span><span style=3D"color:rgb(192,192,192)"> </span><s=
pan style=3D"color:rgb(128,0,128)">A</span><span style=3D"color:rgb(192,192=
,192)"> </span><span style=3D"color:rgb(0,0,0)">{</span></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px"><span style=3D"color:rgb(19=
2,192,192)">  </span><span style=3D"color:rgb(128,128,0)">namespace</span><=
span style=3D"color:rgb(192,192,192)"> </span><span style=3D"color:rgb(128,=
0,128)">B</span><span style=3D"color:rgb(192,192,192)"> </span><span style=
=3D"color:rgb(0,0,0)">{</span></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px"><span style=3D"color:rgb(19=
2,192,192)">    </span><span style=3D"color:rgb(128,128,0)">struct</span><s=
pan style=3D"color:rgb(192,192,192)"> </span><span style=3D"color:rgb(128,0=
,128)">X</span><span style=3D"color:rgb(192,192,192)"> </span><span style=
=3D"color:rgb(0,0,0)">{</span></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px"><span style=3D"color:rgb(19=
2,192,192)">      </span><span style=3D"color:rgb(128,128,0)">struct</span>=
<span style=3D"color:rgb(192,192,192)"> </span><span style=3D"color:rgb(128=
,0,128)">Y</span><span style=3D"color:rgb(192,192,192)"> </span><span style=
=3D"color:rgb(0,0,0)">{</span></pre>
</span><pre style=3D"margin-top:0px;margin-bottom:0px"><span style=3D"color=
:rgb(192,192,192)">        </span><span style=3D"color:rgb(128,128,0)">enum=
</span><span style=3D"color:rgb(192,192,192)"> </span><span style=3D"color:=
rgb(128,128,0)">struct</span><span style=3D"color:rgb(192,192,192)"> </span=
><span style=3D"color:rgb(128,0,128)">E</span><span style=3D"color:rgb(192,=
192,192)"> </span><span style=3D"color:rgb(0,0,0)">:</span><span style=3D"c=
olor:rgb(192,192,192)"> </span><span style=3D"color:rgb(128,128,0)">int</sp=
an><span style=3D"color:rgb(192,192,192)"> </span><span style=3D"color:rgb(=
0,0,0)">{</span></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px"><span style=3D"color:rgb(19=
2,192,192)">          </span><span style=3D"color:rgb(128,0,128)">e0</span>=
<span style=3D"color:rgb(192,192,192)"> </span><span style=3D"color:rgb(0,0=
,0)">=3D</span><span style=3D"color:rgb(192,192,192)"> </span><span style=
=3D"color:rgb(0,0,128)">1</span><span style=3D"color:rgb(0,0,0)">,</span><s=
pan style=3D"color:rgb(192,192,192)"> </span><span style=3D"color:rgb(128,0=
,128)">e1</span><span style=3D"color:rgb(0,0,0)">,</span><span style=3D"col=
or:rgb(192,192,192)"> </span><span style=3D"color:rgb(128,0,128)">e2</span>=
<span style=3D"color:rgb(0,0,0)">,</span></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px"><span style=3D"color:rgb(19=
2,192,192)">        </span><span style=3D"color:rgb(0,0,0)">};</span></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px"><span style=3D"color:rgb(19=
2,192,192)">      </span><span style=3D"color:rgb(0,0,0)">};</span></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px"><span style=3D"color:rgb(19=
2,192,192)">    </span><span style=3D"color:rgb(0,0,0)">};</span></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px"><span style=3D"color:rgb(19=
2,192,192)">  </span><span style=3D"color:rgb(0,0,0)">}</span></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px"><span style=3D"color:rgb(0,=
0,0)">}</span></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px"><br></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px"><span style=3D"color:rgb(12=
8,128,0)">int</span><span style=3D"color:rgb(192,192,192)"> </span><span st=
yle=3D"color:rgb(0,0,0)">main</span><span style=3D"color:rgb(0,0,0)">()</sp=
an><span style=3D"color:rgb(192,192,192)"> </span><span style=3D"color:rgb(=
0,0,0)">{</span></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px"><span style=3D"color:rgb(19=
2,192,192)">  </span><span style=3D"color:rgb(128,128,0)">using</span><span=
 style=3D"color:rgb(192,192,192)"> </span><span style=3D"color:rgb(128,0,12=
8)">E</span><span style=3D"color:rgb(192,192,192)"> </span><span style=3D"c=
olor:rgb(0,0,0)">=3D</span><span style=3D"color:rgb(192,192,192)"> </span><=
span style=3D"color:rgb(128,0,128)">A</span><span style=3D"color:rgb(0,0,0)=
">::</span><span style=3D"color:rgb(128,0,128)">B</span><span style=3D"colo=
r:rgb(0,0,0)">::</span><span style=3D"color:rgb(128,0,128)">X</span><span s=
tyle=3D"color:rgb(0,0,0)">::</span><span style=3D"color:rgb(128,0,128)">Y</=
span><span style=3D"color:rgb(0,0,0)">::</span><span style=3D"color:rgb(128=
,0,128)">E</span><span style=3D"color:rgb(0,0,0)">;</span></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px"><span style=3D"color:rgb(19=
2,192,192)">  </span><span style=3D"color:rgb(128,0,128)">A</span><span sty=
le=3D"color:rgb(0,0,0)">::</span><span style=3D"color:rgb(128,0,128)">B</sp=
an><span style=3D"color:rgb(0,0,0)">::</span><span style=3D"color:rgb(128,0=
,128)">X</span><span style=3D"color:rgb(0,0,0)">::</span><span style=3D"col=
or:rgb(128,0,128)">Y</span><span style=3D"color:rgb(0,0,0)">::</span><span =
style=3D"color:rgb(128,0,128)">E</span><span style=3D"color:rgb(192,192,192=
)"> </span><span style=3D"color:rgb(0,0,0)">var</span><span style=3D"color:=
rgb(192,192,192)"> </span><span style=3D"color:rgb(0,0,0)">=3D</span><span =
style=3D"color:rgb(192,192,192)"> </span><span style=3D"color:rgb(128,0,128=
)">E</span><span style=3D"color:rgb(0,0,0)">::</span><span style=3D"color:r=
gb(128,0,128)">e0</span><span style=3D"color:rgb(0,0,0)">;</span></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px"><span style=3D"color:rgb(19=
2,192,192)">  </span></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px"><span style=3D"color:rgb(19=
2,192,192)">  </span><span style=3D"color:rgb(0,128,0)">//</span><span styl=
e=3D"color:rgb(192,192,192)"> </span><span style=3D"color:rgb(0,128,0)">Thi=
s</span><span style=3D"color:rgb(192,192,192)"> </span><span style=3D"color=
:rgb(0,128,0)">should</span><span style=3D"color:rgb(192,192,192)"> </span>=
<span style=3D"color:rgb(0,128,0)">be</span><span style=3D"color:rgb(192,19=
2,192)"> </span><span style=3D"color:rgb(0,128,0)">legal</span><span style=
=3D"color:rgb(192,192,192)"> </span><span style=3D"color:rgb(0,128,0)">with=
</span><span style=3D"color:rgb(192,192,192)"> </span><span style=3D"color:=
rgb(0,128,0)">the</span><span style=3D"color:rgb(192,192,192)"> </span><spa=
n style=3D"color:rgb(0,128,0)">suggested</span><span style=3D"color:rgb(192=
,192,192)"> </span><span style=3D"color:rgb(0,128,0)">resolution</span></pr=
e><span class=3D"">
<pre style=3D"margin-top:0px;margin-bottom:0px"><span style=3D"color:rgb(19=
2,192,192)">  </span><span style=3D"color:rgb(128,128,0)">using</span><span=
 style=3D"color:rgb(192,192,192)"> </span><span style=3D"color:rgb(128,128,=
0)">namespace</span><span style=3D"color:rgb(192,192,192)"> </span><span st=
yle=3D"color:rgb(128,0,128)">A</span><span style=3D"color:rgb(0,0,0)">::</s=
pan><span style=3D"color:rgb(128,0,128)">B</span><span style=3D"color:rgb(0=
,0,0)">::</span><span style=3D"color:rgb(128,0,128)">X</span><span style=3D=
"color:rgb(0,0,0)">::</span><span style=3D"color:rgb(128,0,128)">Y</span><s=
pan style=3D"color:rgb(0,0,0)">::</span><span style=3D"color:rgb(128,0,128)=
">E</span><span style=3D"color:rgb(0,0,0)">;</span></pre>
</span><pre style=3D"margin-top:0px;margin-bottom:0px"><span style=3D"color=
:rgb(192,192,192)">  </span><span style=3D"color:rgb(128,128,0)">if</span><=
span style=3D"color:rgb(0,0,0)">(</span><span style=3D"color:rgb(0,0,0)">va=
r</span><span style=3D"color:rgb(192,192,192)"> </span><span style=3D"color=
:rgb(0,0,0)">=3D=3D</span><span style=3D"color:rgb(192,192,192)"> </span>e0=
<span style=3D"color:rgb(0,0,0)">){}</span></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px"><span style=3D"color:rgb(19=
2,192,192)">  </span><span style=3D"color:rgb(128,128,0)">if</span><span st=
yle=3D"color:rgb(0,0,0)">((</span><span style=3D"color:rgb(128,128,0)">int<=
/span><span style=3D"color:rgb(0,0,0)">)</span><span style=3D"color:rgb(0,0=
,0)">var</span><span style=3D"color:rgb(192,192,192)"> </span><span style=
=3D"color:rgb(0,0,0)">=3D=3D</span><span style=3D"color:rgb(192,192,192)"> =
</span><span style=3D"color:rgb(0,0,0)">(</span><span style=3D"color:rgb(12=
8,128,0)">int</span><span style=3D"color:rgb(0,0,0)">)</span>e0<span style=
=3D"color:rgb(0,0,0)">){}</span><span style=3D"color:rgb(192,192,192)"> </s=
pan><span style=3D"color:rgb(0,128,0)">//</span><span style=3D"color:rgb(19=
2,192,192)"> </span><span style=3D"color:rgb(0,128,0)">then</span><span sty=
le=3D"color:rgb(192,192,192)"> </span><span style=3D"color:rgb(0,128,0)">so=
</span><span style=3D"color:rgb(192,192,192)"> </span><span style=3D"color:=
rgb(0,128,0)">is</span><span style=3D"color:rgb(192,192,192)"> </span><span=
 style=3D"color:rgb(0,128,0)">this</span></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px"><span style=3D"color:rgb(19=
2,192,192)">  </span></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px"><span style=3D"color:rgb(19=
2,192,192)">  </span><span style=3D"color:rgb(128,128,0)">int</span><span s=
tyle=3D"color:rgb(192,192,192)"> </span><span style=3D"color:rgb(0,0,0)">e0=
</span><span style=3D"color:rgb(192,192,192)"> </span><span style=3D"color:=
rgb(0,0,0)">=3D</span><span style=3D"color:rgb(192,192,192)"> </span><span =
style=3D"color:rgb(0,0,128)">123</span><span style=3D"color:rgb(0,0,0)">;</=
span><span style=3D"color:rgb(192,192,192)"> </span><span style=3D"color:rg=
b(0,128,0)">//</span><span style=3D"color:rgb(192,192,192)"> </span><span s=
tyle=3D"color:rgb(0,128,0)">introducing</span><span style=3D"color:rgb(192,=
192,192)"> </span><span style=3D"color:rgb(0,128,0)">an</span><span style=
=3D"color:rgb(192,192,192)"> </span><span style=3D"color:rgb(0,128,0)">int<=
/span><span style=3D"color:rgb(192,192,192)"> </span><span style=3D"color:r=
gb(0,128,0)">with</span><span style=3D"color:rgb(192,192,192)"> </span><spa=
n style=3D"color:rgb(0,128,0)">the</span><span style=3D"color:rgb(192,192,1=
92)"> </span><span style=3D"color:rgb(0,128,0)">same</span><span style=3D"c=
olor:rgb(192,192,192)"> </span><span style=3D"color:rgb(0,128,0)">identifie=
r</span></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px"><br></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px"><span style=3D"color:rgb(19=
2,192,192)">  </span><span style=3D"color:rgb(0,128,0)">//</span><span styl=
e=3D"color:rgb(192,192,192)"> </span><span style=3D"color:rgb(0,128,0)">cur=
rent</span><span style=3D"color:rgb(192,192,192)"> </span><span style=3D"co=
lor:rgb(0,128,0)">unambiguous</span><span style=3D"color:rgb(192,192,192)">=
 </span><span style=3D"color:rgb(0,128,0)">notation</span></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px"><span style=3D"color:rgb(19=
2,192,192)">  </span><span style=3D"color:rgb(128,128,0)">if</span><span st=
yle=3D"color:rgb(0,0,0)">((</span><span style=3D"color:rgb(128,128,0)">int<=
/span><span style=3D"color:rgb(0,0,0)">)</span><span style=3D"color:rgb(0,0=
,0)">var</span><span style=3D"color:rgb(192,192,192)"> </span><span style=
=3D"color:rgb(0,0,0)">=3D=3D</span><span style=3D"color:rgb(192,192,192)"> =
</span><span style=3D"color:rgb(0,0,0)">(</span><span style=3D"color:rgb(12=
8,128,0)">int</span><span style=3D"color:rgb(0,0,0)">)</span><span style=3D=
"color:rgb(128,128,0)">decltype</span><span style=3D"color:rgb(0,0,0)">(</s=
pan><span style=3D"color:rgb(0,0,0)">var</span><span style=3D"color:rgb(0,0=
,0)">)::</span>e0<span style=3D"color:rgb(0,0,0)">){}</span><span style=3D"=
color:rgb(192,192,192)"> </span><span style=3D"color:rgb(0,128,0)">//</span=
><span style=3D"color:rgb(192,192,192)"> </span><span style=3D"color:rgb(0,=
128,0)">ok:</span><span style=3D"color:rgb(192,192,192)"> </span><span styl=
e=3D"color:rgb(0,128,0)">if</span><span style=3D"color:rgb(192,192,192)"> <=
/span><span style=3D"color:rgb(0,128,0)">var</span><span style=3D"color:rgb=
(192,192,192)"> </span><span style=3D"color:rgb(0,128,0)">=3D=3D</span><spa=
n style=3D"color:rgb(192,192,192)"> </span><span style=3D"color:rgb(0,128,0=
)">1</span></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px"><span style=3D"color:rgb(19=
2,192,192)">  </span><span style=3D"color:rgb(128,128,0)">if</span><span st=
yle=3D"color:rgb(0,0,0)">((</span><span style=3D"color:rgb(128,128,0)">int<=
/span><span style=3D"color:rgb(0,0,0)">)</span><span style=3D"color:rgb(0,0=
,0)">var</span><span style=3D"color:rgb(192,192,192)"> </span><span style=
=3D"color:rgb(0,0,0)">=3D=3D</span><span style=3D"color:rgb(192,192,192)"> =
</span><span style=3D"color:rgb(0,0,0)">(</span><span style=3D"color:rgb(12=
8,128,0)">int</span><span style=3D"color:rgb(0,0,0)">)</span><span style=3D=
"color:rgb(128,0,128)">E</span><span style=3D"color:rgb(0,0,0)">::</span><s=
pan style=3D"color:rgb(128,0,128)">e0</span><span style=3D"color:rgb(0,0,0)=
">){}</span><span style=3D"color:rgb(192,192,192)"> </span><span style=3D"c=
olor:rgb(0,128,0)">//</span><span style=3D"color:rgb(192,192,192)"> </span>=
<span style=3D"color:rgb(0,128,0)">ok:</span><span style=3D"color:rgb(192,1=
92,192)"> </span><span style=3D"color:rgb(0,128,0)">if</span><span style=3D=
"color:rgb(192,192,192)"> </span><span style=3D"color:rgb(0,128,0)">var</sp=
an><span style=3D"color:rgb(192,192,192)"> </span><span style=3D"color:rgb(=
0,128,0)">=3D=3D</span><span style=3D"color:rgb(192,192,192)"> </span><span=
 style=3D"color:rgb(0,128,0)">1</span></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px"><span style=3D"color:rgb(19=
2,192,192)">  </span><span style=3D"color:rgb(128,128,0)">if</span><span st=
yle=3D"color:rgb(0,0,0)">((</span><span style=3D"color:rgb(128,128,0)">int<=
/span><span style=3D"color:rgb(0,0,0)">)</span><span style=3D"color:rgb(0,0=
,0)">var</span><span style=3D"color:rgb(192,192,192)"> </span><span style=
=3D"color:rgb(0,0,0)">=3D=3D</span><span style=3D"color:rgb(192,192,192)"> =
</span><span style=3D"color:rgb(0,0,0)">e0</span><span style=3D"color:rgb(0=
,0,0)">){}</span><span style=3D"color:rgb(192,192,192)"> </span><span style=
=3D"color:rgb(0,128,0)">//</span><span style=3D"color:rgb(192,192,192)"> </=
span><span style=3D"color:rgb(0,128,0)">ok:</span><span style=3D"color:rgb(=
192,192,192)"> </span><span style=3D"color:rgb(0,128,0)">if</span><span sty=
le=3D"color:rgb(192,192,192)"> </span><span style=3D"color:rgb(0,128,0)">va=
r</span><span style=3D"color:rgb(192,192,192)"> </span><span style=3D"color=
:rgb(0,128,0)">=3D=3D</span><span style=3D"color:rgb(192,192,192)"> </span>=
<span style=3D"color:rgb(0,128,0)">123</span></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px"><br></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px"><span style=3D"color:rgb(19=
2,192,192)">  </span><span style=3D"color:rgb(0,128,0)">//</span><span styl=
e=3D"color:rgb(192,192,192)"> </span><span style=3D"color:rgb(0,128,0)">sug=
gested</span><span style=3D"color:rgb(192,192,192)"> </span><span style=3D"=
color:rgb(0,128,0)">notation</span><span style=3D"color:rgb(192,192,192)"> =
</span><span style=3D"color:rgb(0,128,0)">ambiguities</span></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px"><span style=3D"color:rgb(19=
2,192,192)">  </span><span style=3D"color:rgb(128,128,0)">if</span><span st=
yle=3D"color:rgb(0,0,0)">((</span><span style=3D"color:rgb(128,128,0)">int<=
/span><span style=3D"color:rgb(0,0,0)">)</span><span style=3D"color:rgb(0,0=
,0)">var</span><span style=3D"color:rgb(192,192,192)"> </span><span style=
=3D"color:rgb(0,0,0)">=3D=3D</span><span style=3D"color:rgb(192,192,192)"> =
</span><span style=3D"color:rgb(0,0,0)">(</span><span style=3D"color:rgb(12=
8,128,0)">int</span><span style=3D"color:rgb(0,0,0)">)</span><span style=3D=
"color:rgb(0,0,0)">e0</span><span style=3D"color:rgb(0,0,0)">){}</span><spa=
n style=3D"color:rgb(192,192,192)"> </span><span style=3D"color:rgb(0,128,0=
)">//</span><span style=3D"color:rgb(192,192,192)"> </span><span style=3D"c=
olor:rgb(0,128,0)">??</span></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px"><span style=3D"color:rgb(19=
2,192,192)">  </span><span style=3D"color:rgb(128,128,0)">if</span><span st=
yle=3D"color:rgb(0,0,0)">((</span><span style=3D"color:rgb(128,128,0)">int<=
/span><span style=3D"color:rgb(0,0,0)">)</span><span style=3D"color:rgb(0,0=
,0)">e0</span><span style=3D"color:rgb(192,192,192)"> </span><span style=3D=
"color:rgb(0,0,0)">=3D=3D</span><span style=3D"color:rgb(192,192,192)"> </s=
pan><span style=3D"color:rgb(0,0,0)">(</span><span style=3D"color:rgb(128,1=
28,0)">int</span><span style=3D"color:rgb(0,0,0)">)</span><span style=3D"co=
lor:rgb(0,0,0)">var</span><span style=3D"color:rgb(0,0,0)">){}</span><span =
style=3D"color:rgb(192,192,192)"> </span><span style=3D"color:rgb(0,128,0)"=
>//</span><span style=3D"color:rgb(192,192,192)"> </span><span style=3D"col=
or:rgb(0,128,0)">??</span></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px"><br></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px"><span style=3D"color:rgb(19=
2,192,192)">  </span><span style=3D"color:rgb(128,128,0)">switch</span><spa=
n style=3D"color:rgb(0,0,0)">(</span><span style=3D"color:rgb(0,0,0)">var</=
span><span style=3D"color:rgb(0,0,0)">)</span><span style=3D"color:rgb(192,=
192,192)"> </span><span style=3D"color:rgb(0,0,0)">{</span><span style=3D"c=
olor:rgb(192,192,192)"> </span><span style=3D"color:rgb(128,128,0)">case</s=
pan><span style=3D"color:rgb(192,192,192)"> </span><span style=3D"color:rgb=
(0,0,0)">e0</span><span style=3D"color:rgb(0,0,0)">:</span><span style=3D"c=
olor:rgb(192,192,192)"> </span><span style=3D"color:rgb(0,0,0)">;</span><sp=
an style=3D"color:rgb(192,192,192)"> </span><span style=3D"color:rgb(0,0,0)=
">}</span></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px"><span style=3D"color:rgb(19=
2,192,192)">  </span><span style=3D"color:rgb(128,128,0)">switch</span><spa=
n style=3D"color:rgb(0,0,0)">((</span><span style=3D"color:rgb(128,128,0)">=
int</span><span style=3D"color:rgb(0,0,0)">)</span><span style=3D"color:rgb=
(0,0,0)">var</span><span style=3D"color:rgb(0,0,0)">)</span><span style=3D"=
color:rgb(192,192,192)"> </span><span style=3D"color:rgb(0,0,0)">{</span><s=
pan style=3D"color:rgb(192,192,192)"> </span><span style=3D"color:rgb(128,1=
28,0)">case</span><span style=3D"color:rgb(192,192,192)"> </span><span styl=
e=3D"color:rgb(0,0,0)">e0</span><span style=3D"color:rgb(0,0,0)">:</span><s=
pan style=3D"color:rgb(192,192,192)"> </span><span style=3D"color:rgb(0,0,0=
)">;</span><span style=3D"color:rgb(192,192,192)"> </span><span style=3D"co=
lor:rgb(0,0,0)">}</span><span style=3D"color:rgb(192,192,192)"> </span><spa=
n style=3D"color:rgb(0,128,0)">//</span><span style=3D"color:rgb(192,192,19=
2)"> </span><span style=3D"color:rgb(0,128,0)">??</span></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px"><span style=3D"color:rgb(19=
2,192,192)">  </span><span style=3D"color:rgb(128,128,0)">switch</span><spa=
n style=3D"color:rgb(0,0,0)">((</span><span style=3D"color:rgb(128,128,0)">=
int</span><span style=3D"color:rgb(0,0,0)">)</span><span style=3D"color:rgb=
(0,0,0)">var</span><span style=3D"color:rgb(0,0,0)">)</span><span style=3D"=
color:rgb(192,192,192)"> </span><span style=3D"color:rgb(0,0,0)">{</span><s=
pan style=3D"color:rgb(192,192,192)"> </span><span style=3D"color:rgb(128,1=
28,0)">case</span><span style=3D"color:rgb(192,192,192)"> </span><span styl=
e=3D"color:rgb(0,0,0)">(</span><span style=3D"color:rgb(128,128,0)">int</sp=
an><span style=3D"color:rgb(0,0,0)">)</span><span style=3D"color:rgb(0,0,0)=
">e0</span><span style=3D"color:rgb(0,0,0)">:</span><span style=3D"color:rg=
b(192,192,192)"> </span><span style=3D"color:rgb(0,0,0)">;</span><span styl=
e=3D"color:rgb(192,192,192)"> </span><span style=3D"color:rgb(0,0,0)">}</sp=
an><span style=3D"color:rgb(192,192,192)"> </span><span style=3D"color:rgb(=
0,128,0)">//</span><span style=3D"color:rgb(192,192,192)"> </span><span sty=
le=3D"color:rgb(0,128,0)">??</span></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px"><span style=3D"color:rgb(0,=
0,0)">}</span></pre></div><div><pre style=3D"margin-top:0px;margin-bottom:0=
px"></pre></div><div><br></div><div>This could get sorted by prioritizing o=
ne lookup over the other, but I don&#39;t see any universal way of doing th=
is; a resolution ordering that seems logical to some might not be to others=
.. In any case it makes the code more fragile since it would allow either a =
variable to shadow a scoped enumerator or a scoped enumerator to shadow a v=
ariable.</div></div><div class=3D"gmail_extra"><div><div class=3D"h5"><br><=
div class=3D"gmail_quote">On Wed, Oct 29, 2014 at 6:35 AM, Jens Maurer <spa=
n dir=3D"ltr">&lt;<a href=3D"mailto:Jens.Maurer@gmx.net" target=3D"_blank">=
Jens.Maurer@gmx.net</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quo=
te" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"=
><span>On 10/28/2014 11:02 PM, <a href=3D"mailto:corentin.schreiber@cea.fr"=
 target=3D"_blank">corentin.schreiber@cea.fr</a> wrote:<br>
&gt; As for being a major language change Thiago, I do not understand why y=
ou say so (nor do I know the consequences it implies).<br>
<br>
</span>There is no formal classification for something being a &quot;major =
change&quot;.<br>
<br>
However, properly specifying what you want to achieve, including<br>
its interactions with overload resolution and overloaded operators,<br>
seems like no small task.=C2=A0 I doubt the invested effort (including<br>
review effort within WG21) is worth the return.<br>
<br>
I can be convinced otherwise; please show me reasonably solid core<br>
language wording (as a change to the current standard/working draft)<br>
that implements your proposal.<br>
<br>
Thanks,<br>
Jens<br>
<div><div><br>
--<br>
<br>
---<br>
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals%2Bunsubscribe@isocpp.org" target=3D=
"_blank">std-proposals+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
</div></div></blockquote></div><br><br clear=3D"all"><div><br></div></div><=
/div><span class=3D"HOEnZb"><font color=3D"#888888">-- <br>Thibaut LUTZ
</font></span></div><div class=3D"HOEnZb"><div class=3D"h5">

<p></p>

-- <br>
<br>
--- <br>
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org" target=3D"_=
blank">std-proposals+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
</div></div></blockquote></div><br></div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

--485b397dd2931730840506a48a35--

.


Author: Myriachan <myriachan@gmail.com>
Date: Thu, 30 Oct 2014 11:58:33 -0700 (PDT)
Raw View
------=_Part_912_1442935109.1414695513789
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

On Thursday, October 30, 2014 7:17:26 AM UTC-7, David Rodr=C3=ADguez Ibeas =
wrote:
>
> Thibaut,
>
>    The code you present would not lead to ambiguities for the compiler,=
=20
> although it will surely be surprising for the programmer/maintainer. A=20
> using directive (using namespace) does not (at least the current=20
> incarnation) inject the names into the current scope, but makes them=20
> available as if declared in a namespace scope, in the example you provide=
=20
> to the global namespace (first common ancestor of 'main' and the used=20
> namespace). So the local variable hides the name that would be found with=
=20
> the 'using namespace'.
>
>     This might or not be the intention of the suggested proposal. If it=
=20
> is, then there is no ambiguity but there will be surprises (the same that=
=20
> we currently have with using directives [1]). If it is not, then the=20
> suggested proposal would have different behavior than the using directive=
=20
> has today and will confuse everyone even more than we are today (I=20
> personally believe that there cannot be much more than 10 people that=20
> really understand lookup as specified in the language --and this includes=
=20
> compiler implementors).
>
>     David
>
>
But does the proposal make anything *worse* in that regard?

Melissa=20

--=20

---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.

------=_Part_912_1442935109.1414695513789
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On Thursday, October 30, 2014 7:17:26 AM UTC-7, David Rodr=
=C3=ADguez Ibeas wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0=
;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div di=
r=3D"ltr">Thibaut,<div><br>&nbsp; &nbsp;The code you present would not lead=
 to ambiguities for the compiler, although it will surely be surprising for=
 the programmer/maintainer. A using directive (using namespace) does not (a=
t least the current incarnation) inject the names into the current scope, b=
ut makes them available as if declared in a namespace scope, in the example=
 you provide to the global namespace (first common ancestor of 'main' and t=
he used namespace). So the local variable hides the name that would be foun=
d with the 'using namespace'.<br><br>&nbsp; &nbsp; This might or not be the=
 intention of the suggested proposal. If it is, then there is no ambiguity =
but there will be surprises (the same that we currently have with using dir=
ectives [1]). If it is not, then the suggested proposal would have differen=
t behavior than the using directive has today and will confuse everyone eve=
n more than we are today (I personally believe that there cannot be much mo=
re than 10 people that really understand lookup as specified in the languag=
e --and this includes compiler implementors).<br><br>&nbsp; &nbsp; David</d=
iv></div><br></blockquote><div><br>But does the proposal make anything <i>w=
orse</i> in that regard?<br><br>Melissa <br></div></div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_912_1442935109.1414695513789--

.


Author: =?UTF-8?Q?David_Rodr=C3=ADguez_Ibeas?= <dibeas@ieee.org>
Date: Fri, 31 Oct 2014 12:35:05 -0400
Raw View
--e89a8f5029825767920506ba94f5
Content-Type: text/plain; charset=UTF-8

On Thu, Oct 30, 2014 at 2:58 PM, Myriachan <myriachan@gmail.com> wrote:

> But does the proposal make anything *worse* in that regard?
>

Yes it does. We are discussing a new feature and binding that to some
existing syntax leads to one of two things: you buy the existing semantics
(extending the complexity of using-directives to the new use) or you cause
confusion (using-directives behave differently depending on what
"namespace" means).

My point is that we should steer clear of "using namespace" for two
reasons: it comes with the baggage of the current behavior, and it an enum
is *not* a namespace.

David

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

--e89a8f5029825767920506ba94f5
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote">On T=
hu, Oct 30, 2014 at 2:58 PM, Myriachan <span dir=3D"ltr">&lt;<a href=3D"mai=
lto:myriachan@gmail.com" target=3D"_blank">myriachan@gmail.com</a>&gt;</spa=
n> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;b=
order-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div>But does =
the proposal make anything <i>worse</i> in that regard?<br></div></div></bl=
ockquote><div><br>Yes it does. We are discussing a new feature and binding =
that to some existing syntax leads to one of two things: you buy the existi=
ng semantics (extending the complexity of using-directives to the new use) =
or you cause confusion (using-directives behave differently depending on wh=
at &quot;namespace&quot; means).<br><br>My point is that we should steer cl=
ear of &quot;using namespace&quot; for two reasons: it comes with the bagga=
ge of the current behavior, and it an enum is *not* a namespace.<br><br>Dav=
id</div></div></div></div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

--e89a8f5029825767920506ba94f5--

.


Author: Thiago Macieira <thiago@macieira.org>
Date: Fri, 31 Oct 2014 14:13:13 -0700
Raw View
On Friday 31 October 2014 12:35:05 David Rodr=C3=ADguez Ibeas wrote:
> My point is that we should steer clear of "using namespace" for two
> reasons: it comes with the baggage of the current behavior, and it an enu=
m
> is *not* a namespace.

Well, it really depends on how you look at it.

It's not a namespace that was created by the namespace keyword. But it is a=
=20
"name space" in the general sense, like saying that Linux PIDs and thread I=
Ds=20
are allocated from the same namespace (though no C++ namespace keyword was=
=20
harmed in the process).

--=20
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel Open Source Technology Center
      PGP/GPG: 0x6EF45358; fingerprint:
      E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358

--=20

---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.

.


Author: corentin.schreiber@cea.fr
Date: Fri, 31 Oct 2014 16:41:50 -0700 (PDT)
Raw View
------=_Part_145_867286843.1414798910845
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Le vendredi 31 octobre 2014 22:13:19 UTC+1, Thiago Macieira a =C3=A9crit :
>
> On Friday 31 October 2014 12:35:05 David Rodr=C3=ADguez Ibeas wrote:=20
> > My point is that we should steer clear of "using namespace" for two=20
> > reasons: it comes with the baggage of the current behavior, and it an=
=20
> enum=20
> > is *not* a namespace.=20
>
> Well, it really depends on how you look at it.=20
>
> It's not a namespace that was created by the namespace keyword. But it is=
=20
> a=20
> "name space" in the general sense, like saying that Linux PIDs and thread=
=20
> IDs=20
> are allocated from the same namespace (though no C++ namespace keyword wa=
s=20
> harmed in the process).=20
>

I agree. I am not very fond of the "using enum E;" syntax, because it does=
=20
not state
clearly its intent. It can be understood as a statement that imports only=
=20
the type of E
into the current scope, i.e. "using E;", and which is just specifying that=
=20
"E" is an enum
and not some other kind of type (sort of like a forward declaration).
The syntax "using namespace" on the other hand already has the semantic of=
=20
importing
a whole name space into the current scope, so I suppose it would be more=20
straightforward to understand (that is, as long as you agree with Thiago's=
=20
point above
on the generic sense of a "name space").

--=20

---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.

------=_Part_145_867286843.1414798910845
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Le vendredi 31 octobre 2014 22:13:19 UTC+1, Thiago Macieir=
a a =C3=A9crit&nbsp;:<blockquote class=3D"gmail_quote" style=3D"margin: 0;m=
argin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">On Friday=
 31 October 2014 12:35:05 David Rodr=C3=ADguez Ibeas wrote:
<br>&gt; My point is that we should steer clear of "using namespace" for tw=
o
<br>&gt; reasons: it comes with the baggage of the current behavior, and it=
 an enum
<br>&gt; is *not* a namespace.
<br>
<br>Well, it really depends on how you look at it.
<br>
<br>It's not a namespace that was created by the namespace keyword. But it =
is a=20
<br>"name space" in the general sense, like saying that Linux PIDs and thre=
ad IDs=20
<br>are allocated from the same namespace (though no C++ namespace keyword =
was=20
<br>harmed in the process).
<br></blockquote><div><br>I agree. I am not very fond of the "using enum E;=
" syntax, because it does not state<br>clearly its intent. It can be unders=
tood as a statement that imports only the type of E<br>into the current sco=
pe, i.e. "using E;", and which is just specifying  that "E" is an enum<br>a=
nd not some other kind of type (sort of like a forward declaration).<br>The=
 syntax "using namespace" on the other hand already has the semantic of imp=
orting<br>a whole name space into the current scope, so I suppose it would =
be more <br>straightforward to understand (that is, as long as you agree wi=
th Thiago's point above<br>on the generic sense of a "name space").<br><br>=
</div></div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_145_867286843.1414798910845--

.


Author: Christopher <christopherhallock@gmail.com>
Date: Fri, 31 Oct 2014 19:52:49 -0700 (PDT)
Raw View
------=_Part_287_841249931.1414810369363
Content-Type: text/plain; charset=UTF-8


>
> My point is that we should steer clear of "using namespace" for two
> reasons: it comes with the baggage of the current behavior, and it an enum
> is *not* a namespace.
>

How about "using enum namespace E;"?

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

------=_Part_287_841249931.1414810369363
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><blockquote class=3D"gmail_quote" style=3D"margin: 0;margi=
n-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"l=
tr"><div><div class=3D"gmail_quote"><div>My point is that we should steer c=
lear of "using namespace" for two reasons: it comes with the baggage of the=
 current behavior, and it an enum is *not* a namespace.<br></div></div></di=
v></div></blockquote><div><br>How about "<span style=3D"font-family: courie=
r new,monospace;">using enum namespace E;</span>"?<br></div></div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_287_841249931.1414810369363--

.


Author: Myriachan <myriachan@gmail.com>
Date: Sat, 1 Nov 2014 20:21:49 -0700 (PDT)
Raw View
------=_Part_705_927655599.1414898509955
Content-Type: text/plain; charset=UTF-8

On Friday, October 31, 2014 7:52:49 PM UTC-7, Christopher wrote:
>
> My point is that we should steer clear of "using namespace" for two
>> reasons: it comes with the baggage of the current behavior, and it an enum
>> is *not* a namespace.
>>
>
> How about "using enum namespace E;"?
>

That could work, because the position of the namespace keyword breaks up
the parsing...

As another reason that "using enum X", "using class X"... are bad:  If an
identifier is both a type and a non-type, if you want to "using" the type
rather than the non-type, you use the typename keyword, as in "using
typename X::Y".   "using class X::Y" and "using typename X::Y" would both
be legal, but have very different effects.

That's one reason I mentioned "using namespace" as the possible way to
request this import.  It matches the semantics of "using namespace", and it
doesn't have the awkwardness of "using enum" / "using class".  I don't like
it using the word namespace for a non-namespace, but to me, it seems better
than the alternatives.

Another somewhat awkward alternative is:

namespace meow = A::B::X::Y::E;
using namespace meow;

or

namespace = A::B::X::Y::E;

which would be an anonymous namespace combined with the = syntax.  To truly
be useful, this would have to ignore access-specifiers--such as if E were
private within Y--and only enforce them upon use of the final name.

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

------=_Part_705_927655599.1414898509955
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On Friday, October 31, 2014 7:52:49 PM UTC-7, Christopher =
wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8=
ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><blockq=
uote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:=
1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div><div class=3D"gmail_=
quote"><div>My point is that we should steer clear of "using namespace" for=
 two reasons: it comes with the baggage of the current behavior, and it an =
enum is *not* a namespace.<br></div></div></div></div></blockquote><div><br=
>How about "<span style=3D"font-family:courier new,monospace">using enum na=
mespace E;</span>"?<br></div></div></blockquote><div><br>That could work, b=
ecause the position of the namespace keyword breaks up the parsing...<br><b=
r>As another reason that "using enum X", "using class X"... are bad:&nbsp; =
If an identifier is both a type and a non-type, if you want to "using" the =
type rather than the non-type, you use the typename keyword, as in "using t=
ypename X::Y". &nbsp; "using class X::Y" and "using typename X::Y" would bo=
th be legal, but have very different effects.<br><br>That's one reason I me=
ntioned "using namespace" as the possible way to request this import.&nbsp;=
 It matches the semantics of "using namespace", and it doesn't have the awk=
wardness of "using enum" / "using class".&nbsp; I don't like it using the w=
ord namespace for a non-namespace, but to me, it seems better than the alte=
rnatives.<br><br>Another somewhat awkward alternative is:<br><br>namespace =
meow =3D A::B::X::Y::E;<br>using namespace meow;<br><br>or<br><br>namespace=
 =3D A::B::X::Y::E;<br><br>which would be an anonymous namespace combined w=
ith the =3D syntax.&nbsp; To truly be useful, this would have to ignore acc=
ess-specifiers--such as if E were private within Y--and only enforce them u=
pon use of the final name.<br></div></div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_705_927655599.1414898509955--

.