Topic: Question about a how a "using enum" would work
Author: Myriachan <myriachan@gmail.com>
Date: Thu, 12 May 2016 18:35:54 -0700 (PDT)
Raw View
------=_Part_1435_2113277475.1463103354406
Content-Type: multipart/alternative;
boundary="----=_Part_1436_1200932494.1463103354407"
------=_Part_1436_1200932494.1463103354407
Content-Type: text/plain; charset=UTF-8
A while back, I posted on here asking about the possibility of adding a "using
enum" to the Standard, to provide the ability to have the older style of
enumeration scoping while still getting the benefits of "enum class". I
was thinking of writing a formal proposal for it.
I did have a question about "using enum", though: Should "using enum X"
also pull X itself into the current scope, as if you did "using X" as well?
For example:
namespace N
{
enum class E
{
E1,
E2,
};
}
using enum N::E;
static_assert(E1 == E1); // OK: enumerators pulled in
static_assert(static_cast<E>(0) == E1); // ???: but what about "E" itself?
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.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/eaebc79a-6f44-4eb4-a59b-f06c2f401864%40isocpp.org.
------=_Part_1436_1200932494.1463103354407
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">A while back, I posted on here asking about the possibilit=
y of adding a "<span style=3D"font-family: courier new,monospace;">usi=
ng enum</span>" to the Standard, to provide the ability to have the ol=
der style of enumeration scoping while still getting the benefits of "=
<span style=3D"font-family: courier new,monospace;">enum class</span>"=
..=C2=A0 I was thinking of writing a formal proposal for it.<br><br>I did ha=
ve a question about "<span style=3D"font-family: courier new,monospace=
;">using enum</span>", though: Should "<span style=3D"font-family=
: courier new,monospace;">using enum X</span>" also pull <span style=
=3D"font-family: courier new,monospace;">X</span> itself into the current s=
cope, as if you did "<span style=3D"font-family: courier new,monospace=
;">using X</span>" as well?<br><br>For example:<br><br><div class=3D"p=
rettyprint" style=3D"background-color: rgb(250, 250, 250); border-color: rg=
b(187, 187, 187); border-style: solid; border-width: 1px; word-wrap: break-=
word;"><code class=3D"prettyprint"><div class=3D"subprettyprint"><span styl=
e=3D"color: #008;" class=3D"styled-by-prettify">namespace</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> N<br></span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><span style=3D"c=
olor: #008;" class=3D"styled-by-prettify">enum</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" cl=
ass=3D"styled-by-prettify">class</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> E<br>=C2=A0 =C2=A0 </span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">{</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 E1</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 E2<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">};</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">}</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"><br><br></span><span style=3D"color=
: #008;" class=3D"styled-by-prettify">using</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">enum</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> N</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: #660;" class=3D"styled-by-prettify">;</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span=
style=3D"color: #008;" class=3D"styled-by-prettify">static_assert</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">E1 </span><span style=3D"col=
or: #660;" class=3D"styled-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-prettify">);</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"> =C2=A0</span><span style=3D"color: #800;" class=3D"st=
yled-by-prettify">// OK: enumerators pulled in</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #008;"=
class=3D"styled-by-prettify">static_assert</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">(</span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">static_cast</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify"><</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify">E</span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">>(</span><span style=3D"color: #066;" class=3D"styled-by-prett=
ify">0</span><span style=3D"color: #660;" class=3D"styled-by-prettify">)</s=
pan><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 sty=
le=3D"color: #000;" class=3D"styled-by-prettify"> E1</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">);</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> =C2=A0</span><span style=3D"color: #800;=
" class=3D"styled-by-prettify">// ???: but what about "E" itself?=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span=
></div></code></div><br><br>Melissa<br></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/eaebc79a-6f44-4eb4-a59b-f06c2f401864%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/eaebc79a-6f44-4eb4-a59b-f06c2f401864=
%40isocpp.org</a>.<br />
------=_Part_1436_1200932494.1463103354407--
------=_Part_1435_2113277475.1463103354406--
.
Author: Zhihao Yuan <zy@miator.net>
Date: Thu, 12 May 2016 21:10:06 -0500
Raw View
--001a1145ea8e0beb0d0532afc661
Content-Type: text/plain; charset=UTF-8
On May 12, 2016 8:35 PM, "Myriachan" <myriachan@gmail.com> wrote:
>
> A while back, I posted on here asking about the possibility of adding a
"using enum" to the Standard, to provide the ability to have the older
style of enumeration scoping while still getting the benefits of "enum
class". I was thinking of writing a formal proposal for it.
>
I like this idea. I often, in some implementation code, choose unscoped
enums just because I cannot `switch` on the scoped ones without lots of
typing.
> I did have a question about "using enum", though: Should "using enum X"
also pull X itself into the current scope, as if you did "using X" as well?
>
Not doing so looks more orthogonal.
--
Zhihao
--
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.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAGsORuCCJeSEEXCv9RRay_%2BJBRfvHbuoUBKed%3Dyk5N-yXOQ4fA%40mail.gmail.com.
--001a1145ea8e0beb0d0532afc661
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<p dir=3D"ltr"><br>
On May 12, 2016 8:35 PM, "Myriachan" <<a href=3D"mailto:myriac=
han@gmail.com">myriachan@gmail.com</a>> wrote:<br>
><br>
> A while back, I posted on here asking about the possibility of adding =
a "using enum" to the Standard, to provide the ability to have th=
e older style of enumeration scoping while still getting the benefits of &q=
uot;enum class".=C2=A0 I was thinking of writing a formal proposal for=
it.<br>
></p>
<p dir=3D"ltr">I like this idea.=C2=A0 I often, in some implementation code=
, choose unscoped enums just because I cannot `switch` on the scoped ones w=
ithout lots of typing.</p>
<p dir=3D"ltr">> I did have a question about "using enum", tho=
ugh: Should "using enum X" also pull X itself into the current sc=
ope, as if you did "using X" as well?<br>
></p>
<p dir=3D"ltr">Not doing so looks more orthogonal.</p>
<p dir=3D"ltr">--<br>
Zhihao</p>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CAGsORuCCJeSEEXCv9RRay_%2BJBRfvHbuoUB=
Ked%3Dyk5N-yXOQ4fA%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter"=
>https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAGsORuCCJeSE=
EXCv9RRay_%2BJBRfvHbuoUBKed%3Dyk5N-yXOQ4fA%40mail.gmail.com</a>.<br />
--001a1145ea8e0beb0d0532afc661--
.
Author: Chris Hallock <christopherhallock@gmail.com>
Date: Thu, 12 May 2016 19:10:41 -0700 (PDT)
Raw View
------=_Part_1429_1882851273.1463105441517
Content-Type: multipart/alternative;
boundary="----=_Part_1430_1694200431.1463105441517"
------=_Part_1430_1694200431.1463105441517
Content-Type: text/plain; charset=UTF-8
"using namespace ::x::y::z" doesn't bring namespace z into scope, only its
contents. I'd think it'd be confusing if "using enum a::b::c" didn't behave
similarly.
--
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.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/632592c2-9f9f-44fd-b74e-714de0673718%40isocpp.org.
------=_Part_1430_1694200431.1463105441517
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">"<span style=3D"font-family: courier new,monospace;">=
using namespace ::x::y::z</span>" doesn't bring namespace <span st=
yle=3D"font-family: courier new,monospace;">z</span> into scope, only its c=
ontents. I'd think it'd be confusing if "<span style=3D"font-f=
amily: courier new,monospace;">using enum a::b::c</span>" didn't b=
ehave similarly.<br></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/632592c2-9f9f-44fd-b74e-714de0673718%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/632592c2-9f9f-44fd-b74e-714de0673718=
%40isocpp.org</a>.<br />
------=_Part_1430_1694200431.1463105441517--
------=_Part_1429_1882851273.1463105441517--
.
Author: Myriachan <myriachan@gmail.com>
Date: Fri, 13 May 2016 12:31:44 -0700 (PDT)
Raw View
------=_Part_2523_1775706084.1463167904643
Content-Type: multipart/alternative;
boundary="----=_Part_2524_1312490066.1463167904650"
------=_Part_2524_1312490066.1463167904650
Content-Type: text/plain; charset=UTF-8
On Thursday, May 12, 2016 at 7:10:17 PM UTC-7, Zhihao Yuan wrote:
>
> > I did have a question about "using enum", though: Should "using enum X"
> also pull X itself into the current scope, as if you did "using X" as well?
>
> >
>
> Not doing so looks more orthogonal.
>
>
On Thursday, May 12, 2016 at 7:10:41 PM UTC-7, Chris Hallock wrote:
>
> "using namespace ::x::y::z" doesn't bring namespace z into scope, only
> its contents. I'd think it'd be confusing if "using enum a::b::c" didn't
> behave similarly.
>
Now I feel dumb; I didn't even think of it like that. Of course it
shouldn't bring it into scope.
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.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/f5702909-2fcd-4594-8321-af911c3337ed%40isocpp.org.
------=_Part_2524_1312490066.1463167904650
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Thursday, May 12, 2016 at 7:10:17 PM UTC-7, Zhihao Yuan=
wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.=
8ex;border-left: 1px #ccc solid;padding-left: 1ex;">> I did have a quest=
ion about "using enum", though:=20
Should "using enum X" also pull X itself into the current scope, =
as if=20
you did "using X" as well?<br><p dir=3D"ltr">
></p>
<p dir=3D"ltr">Not doing so looks more orthogonal.</p><br></blockquote><br>=
On Thursday, May 12, 2016 at 7:10:41 PM UTC-7, Chris Hallock wrote:<blockqu=
ote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left=
: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr">"<span style=3D"=
font-family:courier new,monospace">using namespace ::x::y::z</span>" d=
oesn't bring namespace <span style=3D"font-family:courier new,monospace=
">z</span> into scope, only its contents. I'd think it'd be confusi=
ng if "<span style=3D"font-family:courier new,monospace">using enum a:=
:b::c</span>" didn't behave similarly.<br></div></blockquote><div>=
<br><br>Now I feel dumb; I didn't even think of it like that.=C2=A0 Of =
course it shouldn't bring it into scope.<br><br>Melissa<br>=C2=A0</div>=
</div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/f5702909-2fcd-4594-8321-af911c3337ed%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/f5702909-2fcd-4594-8321-af911c3337ed=
%40isocpp.org</a>.<br />
------=_Part_2524_1312490066.1463167904650--
------=_Part_2523_1775706084.1463167904643--
.