220 41505 <CAANG=kXAZbiVoBQMQZd2g1nbVnk+FnYMetjrNcEwpS3Pph4SBQ@mail.gmail.com> article
Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail
From: =?UTF-8?B?R2HFoXBlciBBxb5tYW4=?= <gasper.azman@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Re: Should names used in the initializer of an
 object of scoped enumeration type be looked up in the scope of the enum?
Date: Tue, 26 Feb 2019 14:44:30 +0000
Approved: news@gmane.org
Message-ID: <CAANG=kXAZbiVoBQMQZd2g1nbVnk+FnYMetjrNcEwpS3Pph4SBQ@mail.gmail.com>
References: <CAMmfjbP44DFNHwVogEBL+LHjRXrK2hOZH-5LQLgVDmK=JSoqcg@mail.gmail.com>
 <f2442186-7637-487d-ba01-919b6ef9f3e7@isocpp.org>
Reply-To: std-proposals@isocpp.org
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary="000000000000ed10bd0582cd1890"
Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226";
	logging-data="35009"; mail-complaints-to="usenet@blaine.gmane.org"
To: std-proposals@isocpp.org, mobile.schewe@gmail.com
Original-X-From: std-proposals+bncBDRYVJ6TVYBRBW5B2XRQKGQEPBHPAQI@isocpp.org Tue Feb 26 15:44:45 2019
Return-path: <std-proposals+bncBDRYVJ6TVYBRBW5B2XRQKGQEPBHPAQI@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-lf1-f69.google.com ([209.85.167.69])
	by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
	(Exim 4.89)
	(envelope-from <std-proposals+bncBDRYVJ6TVYBRBW5B2XRQKGQEPBHPAQI@isocpp.org>)
	id 1gydyP-0008zx-1I
	for gclcip-std-proposals@m.gmane.org; Tue, 26 Feb 2019 15:44:45 +0100
Original-Received: by mail-lf1-f69.google.com with SMTP id i203sf2369022lfg.10
        for <gclcip-std-proposals@m.gmane.org>; Tue, 26 Feb 2019 06:44:44 -0800 (PST)
ARC-Seal: i=2; a=rsa-sha256; t=1551192284; cv=pass;
        d=google.com; s=arc-20160816;
        b=myLJgNvfPC9+C2th8UfRYE6UNPuRz4hh1TOpYZZ0AoTikiyAwrVJJ4oOuutk6jhKkF
         z+BX4Eyg31HVtOtRz44dlfiCKjjaEcab4VupVw3qjmpv+gfXmCz7EmJ8ptej0BTzSHdI
         XcOMJqphISd5fdK3e7WfEMEmOYW74yudQ/8wKoXnvKGExF/ZAZRjk8z8G1iaNQD7ESR1
         sE96jpzbitCU3CkGRu+7ROwCBPVSXz8zSyJi7g4VfwB6jH2KB1xw6QoKWNYNTjT2JIH4
         WUI0gywbBvbWD1FQ6ITsHUEZLydSvYLVcSn38um4/Id8ISEVyq7fYo9lIHgLsL1R7GC+
         zn6A==
ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post
         :list-id:mailing-list:precedence:reply-to:to:subject:message-id:date
         :from:in-reply-to:references:mime-version:dkim-signature;
        bh=o6iWOy6eJ+4JrDN1MTGZVgMKwb/OskOCV93qBNQ2/eg=;
        b=uJhWhvGZYvt9U+nwLL/h/r8nJGip7ZgpIdQKT3fslASR1fKbhTvWK+FBzF80+LMLyq
         CpnK2RARK7cRD6u0Or7gWT+zXxGTF7duzYyPkvgguyJ3YUnd2HOf3HKGKCJ2HANqvBNV
         9yBa7wVOsSOXljj+Ko6TXBmTGQPfThjLlmSZOS+4BRZhEXc4SEFcsCttwqJ98Vf6Snpw
         xw+aIuq4EEHIK6Fx1AYhy6JR+LIZr1yBYyGgqwTnD3gA76qepschMUD3Au5XMYApmazP
         DM3Tv+trFKKsKJPNa5mR0SZQLGJcSlPhqGO2aEtzBn6HgbIVdbmwysDTwgP5yZYle2jK
         XwiQ==
ARC-Authentication-Results: i=2; mx.google.com;
       dkim=pass header.i=@gmail.com header.s=20161025 header.b=HGZU51cS;
       spf=pass (google.com: domain of gasper.azman@gmail.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=gasper.azman@gmail.com;
       dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=mime-version:references:in-reply-to:from:date:message-id:subject:to
         :x-original-sender:x-original-authentication-results:reply-to
         :precedence:mailing-list:list-id:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=o6iWOy6eJ+4JrDN1MTGZVgMKwb/OskOCV93qBNQ2/eg=;
        b=1deHQNwXgzI1JJOZA6XK0gyomCa7tmfhCC+P6JkyP1La7pO42wKw3LvnFQUxqDOlBk
         7g5kgUqmrOl3UMKmhat1PS9sNBBFm8cguY1DlAS/IFCAxc7x6Rgg6/2ebeuvAvFi3oFt
         mP/BvLZnm4kevmj3ZWxDu2yVdDI8sR+4Yois5n5yIkn3uLOEnPt172WHCl4UJtZTqv6d
         eEbvjIQAUQkLZQJJFwI4UY4/2al3NNc1P1Lq2GoIRzYa320ZWqtnA3/4l54R2TIAlUgP
         16dP/HYQrcw+ER8Vfws7fqwx5PwCuFkkneMJAXl+MeTE39xw7jVXNzA76hGA2cMaYKQA
         LXjw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:mime-version:references:in-reply-to:from:date
         :message-id:subject:to:x-original-sender
         :x-original-authentication-results:reply-to:precedence:mailing-list
         :list-id:x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=o6iWOy6eJ+4JrDN1MTGZVgMKwb/OskOCV93qBNQ2/eg=;
        b=Y5+wjp5lOc52UOxjNbm+KsPBWlFpV4RSbwgWGAH5/jFTMJbXknMLLZx1OtCepbNaxS
         wBeKLzB2vcpxXWJtwxGY2YrWb5P+2dV/rIaS95Ce96iMK3Cptodr6pq2/ZrHrPFs1NSR
         7c1s0eE/qJn0lfCKXrx/2+6f7fo02titoqYP8kLs5YHvMFmuHvGZCcaBr4QNR6Seynwk
         OuIH/yAd50j8dTzSVmMiLaHp+sJH8Gs0AeHIiitJjhYNXztn0jL0DMwEpYAfjmmtJxMG
         kofZETC10B1FCjTS5aLBxPaDBAp6h9gfapZ0OC73lOtlx7YPRZWpQGb5ZTY4SmsJCQMZ
         cQKQ==
X-Gm-Message-State: AHQUAubEv2qAJJcVZ36hrUBQLDnt9eQ311JRehqjgipCuYEFFvaV1l8R
	JL2SrlKKCeveQdBUsbR2lxno1w==
X-Google-Smtp-Source: AHgI3IY9Q9Itiktxlk33lU2l7N79LUMSgAzvFkuQzsTUQxSXoQfr0m7wqlW8n5hCEgw+a5G7rsORzQ==
X-Received: by 2002:a2e:447:: with SMTP id 68mr1072524lje.0.1551192284409;
        Tue, 26 Feb 2019 06:44:44 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 2002:a2e:5d5d:: with SMTP id r90ls993526ljb.7.gmail; Tue, 26 Feb
 2019 06:44:42 -0800 (PST)
X-Received: by 2002:a2e:2c3:: with SMTP id y64mr11665184lje.131.1551192282277;
        Tue, 26 Feb 2019 06:44:42 -0800 (PST)
ARC-Seal: i=1; a=rsa-sha256; t=1551192282; cv=none;
        d=google.com; s=arc-20160816;
        b=YVxcvIbvx5T3uqQXZJTJkQirxlHVjkg7TDy/YzLBaMDA1KIzTaQN9qrfYlK7sQniYK
         C/1ucPpAtx0tEbFNGMeMHt8xIpmve7i/UGdcSoE8CAfW5vlQnoJKaawsjl0bbMfCeVZ2
         v9BzYDpsShj3nT6U3X9hFz5H78VywDuWqtCNtv8yL5vado2GsEArydXu3h5OPi0hY43a
         kRqKP8GN7kC9lax2Z93iqLnSWi209LRNhEah9hYZcyJ3PxA8WlVrflWUyy8xGrYtV8vb
         uCRad1VUa055Z0oUOLGpWKz4HKocoG2mTaNvxxPKa7SVuL1UAE9bpfPzqeFSH5uhbobL
         Hg4A==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=to:subject:message-id:date:from:in-reply-to:references:mime-version
         :dkim-signature;
        bh=f749WzLBpyIootBSUuDXUNNRApaV022lAQv9bhRbxQA=;
        b=EakxgJT2cr6wzSo7VU6ibGEDsSdd7RYJ09ZIMfBprAWbyd1P1wX/eTh2KViCdbSQul
         KOm8l8kuQeXZMFSH2ftrIotSto/9gmCdtw8ZW/VTbi5gXn80ShdstYAzYiq+JdA+tUUC
         DMUUBMXA0KwILIkH60cK2NwvLblTa0pN12JtBDhV3kbWLAGZlKkUz1OzNwB0t0wdlhqO
         3S0B/TH23tluAIX9e1MT4j6WuyWzxMTmjNsBFnb/wd0e2G12TeXXG2CXrMfAPLTjhx7S
         1wQGE0ov/lPIfpyuLXSFb9Ddshi/a+dhEUTS9It3Tz4SAYaj1PStgTKT+WzRBB6fTCXM
         mboA==
ARC-Authentication-Results: i=1; mx.google.com;
       dkim=pass header.i=@gmail.com header.s=20161025 header.b=HGZU51cS;
       spf=pass (google.com: domain of gasper.azman@gmail.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=gasper.azman@gmail.com;
       dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com
Original-Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41])
        by mx.google.com with SMTPS id v18sor7191686ljc.35.2019.02.26.06.44.42
        for <std-proposals@isocpp.org>
        (Google Transport Security);
        Tue, 26 Feb 2019 06:44:42 -0800 (PST)
Received-SPF: pass (google.com: domain of gasper.azman@gmail.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41;
X-Received: by 2002:a2e:6501:: with SMTP id z1mr13685058ljb.101.1551192281646;
 Tue, 26 Feb 2019 06:44:41 -0800 (PST)
In-Reply-To: <f2442186-7637-487d-ba01-919b6ef9f3e7@isocpp.org>
X-Original-Sender: gasper.azman@gmail.com
X-Original-Authentication-Results: mx.google.com;       dkim=pass
 header.i=@gmail.com header.s=20161025 header.b=HGZU51cS;       spf=pass
 (google.com: domain of gasper.azman@gmail.com designates 209.85.220.41 as
 permitted sender) smtp.mailfrom=gasper.azman@gmail.com;       dmarc=pass
 (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Google-Group-Id: 399137483710
List-Post: <https://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <https://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <https://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:std-proposals+subscribe@isocpp.org>
List-Unsubscribe: <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>,
 <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:41505
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/41505>

--000000000000ed10bd0582cd1890
Content-Type: text/plain; charset="UTF-8"

That's not how lookup works :). You need to figure out what type your
arguments are *before* you resolve the call.

However, as a partial fix to your predicament, my paper "Using Enum" made
it to C++20.
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1099r3.html

On Tue, Feb 26, 2019 at 2:17 PM <mobile.schewe@gmail.com> wrote:

> I use enums quite a bit in my code as it is nice to have strongly typed
> values used for passing to functions and switching.
>
> I'd like to propose the following as the name of such code:
> Argument Dependent Name Lookup for Strongly Typed Enums
>
> ADNL is already used for variables and methods within the current scope
> such as inside the same class or namespace,
> but enums are still a case where the scope strongly suggests that the
> value should be a member of an enum, yet must still be fully qualified.
>
> Let me give a few examples:
>
> enum class SpacialUnit {
>     Inch,
>     Millimeter,
>     Point,
>     Pixel,
> };
>
>
> // assignment to a variable cannot be anything other than the type of the
> variable
> SpacialUnit unit = Inch;
>
>
> // passing to a function that requires that type
> Translate(10, Inch);
> // where Translate is declared:
> void Translate(int, SpacialUnit);
>
>
> // returning from a function that declares that type
> SpacialUnit GetUnit() {
>     return Inch;
> }
>
>
> // switching on a variable of that type
> SpacialUnit unit;
> switch (unit) {
>     case Inch: break;
>     case Millimeter: break;
> }
>
>
> // passing as a constexpr value to a template that declares argument type
> template <SpacialUnit unit>
> class Rectangle {
>     ...
> };
>
> Rectangle<Inch> saeRect;
>
>
> In every single one of those cases mentioned above, there is no other
> possible value besides a member of the enum that can be accepted without
> explicit casting.
> So why should we be required to qualify the enum name in these cases?
>
> --
> 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/f2442186-7637-487d-ba01-919b6ef9f3e7%40isocpp.org
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/f2442186-7637-487d-ba01-919b6ef9f3e7%40isocpp.org?utm_medium=email&utm_source=footer>
> .
>

-- 
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/CAANG%3DkXAZbiVoBQMQZd2g1nbVnk%2BFnYMetjrNcEwpS3Pph4SBQ%40mail.gmail.com.

--000000000000ed10bd0582cd1890
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div dir=3D"ltr">That&#39;s not how lookup works :). You n=
eed to figure out what type your arguments are *before* you resolve the cal=
l.<div><br></div><div>However, as a partial fix to your predicament, my pap=
er &quot;Using Enum&quot; made it to C++20. <a href=3D"http://www.open-std.=
org/jtc1/sc22/wg21/docs/papers/2019/p1099r3.html">http://www.open-std.org/j=
tc1/sc22/wg21/docs/papers/2019/p1099r3.html</a></div></div></div><br><div c=
lass=3D"gmail_quote"><div dir=3D"ltr" class=3D"gmail_attr">On Tue, Feb 26, =
2019 at 2:17 PM &lt;<a href=3D"mailto:mobile.schewe@gmail.com">mobile.schew=
e@gmail.com</a>&gt; wrote:<br></div><blockquote class=3D"gmail_quote" style=
=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding=
-left:1ex"><div dir=3D"ltr">I use enums quite a bit in my code as it is nic=
e to have strongly typed values used for passing to functions and switching=
..<div><br></div><div>I&#39;d like to propose the following as the name of s=
uch code:</div><div>Argument Dependent Name Lookup for Strongly Typed Enums=
<br></div><div><br></div><div>ADNL is already used for variables and method=
s within the current scope such as inside the same class or namespace,</div=
><div>but enums are still a case where the scope strongly suggests that the=
 value should be a member of an enum, yet must still be fully qualified.</d=
iv><div><br></div><div>Let me give a few examples:</div><div><br></div><div=
><div class=3D"gmail-m_-6659342346752754237prettyprint" style=3D"background=
-color:rgb(250,250,250);border-color:rgb(187,187,187);border-style:solid;bo=
rder-width:1px"><code class=3D"gmail-m_-6659342346752754237prettyprint"><di=
v class=3D"gmail-m_-6659342346752754237subprettyprint"><span style=3D"color=
:rgb(0,0,136)" class=3D"gmail-m_-6659342346752754237styled-by-prettify">enu=
m</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_-6659342346752754=
237styled-by-prettify"> </span><span style=3D"color:rgb(0,0,136)" class=3D"=
gmail-m_-6659342346752754237styled-by-prettify">class</span><span style=3D"=
color:rgb(0,0,0)" class=3D"gmail-m_-6659342346752754237styled-by-prettify">=
 </span><span style=3D"color:rgb(102,0,102)" class=3D"gmail-m_-665934234675=
2754237styled-by-prettify">SpacialUnit</span><span style=3D"color:rgb(0,0,0=
)" class=3D"gmail-m_-6659342346752754237styled-by-prettify">=C2=A0</span><s=
pan style=3D"color:rgb(102,102,0)" class=3D"gmail-m_-6659342346752754237sty=
led-by-prettify">{</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_=
-6659342346752754237styled-by-prettify"><br>=C2=A0 =C2=A0 </span><span styl=
e=3D"color:rgb(102,0,102)" class=3D"gmail-m_-6659342346752754237styled-by-p=
rettify">Inch</span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_-=
6659342346752754237styled-by-prettify">,</span><span style=3D"color:rgb(0,0=
,0)" class=3D"gmail-m_-6659342346752754237styled-by-prettify"><br>=C2=A0 =
=C2=A0 </span><span style=3D"color:rgb(102,0,102)" class=3D"gmail-m_-665934=
2346752754237styled-by-prettify">Millimeter</span><span style=3D"color:rgb(=
102,102,0)" class=3D"gmail-m_-6659342346752754237styled-by-prettify">,</spa=
n></div><div class=3D"gmail-m_-6659342346752754237subprettyprint"><span cla=
ss=3D"gmail-m_-6659342346752754237styled-by-prettify"><font color=3D"#66660=
0">=C2=A0 =C2=A0 Point,<br>=C2=A0 =C2=A0 Pixel,<br></font></span><span styl=
e=3D"color:rgb(102,102,0)" class=3D"gmail-m_-6659342346752754237styled-by-p=
rettify">};<br><br><br>// assignment to a variable cannot be anything other=
 than the type of the variable<br>SpacialUnit unit =3D Inch;<br><br><br>// =
passing to a function that requires that type<br>Translate(10, Inch);<br>//=
 where Translate is declared:<br>void Translate(int, SpacialUnit);<br><br><=
br>// returning from a function that declares that type<br>SpacialUnit GetU=
nit() {<br>=C2=A0 =C2=A0 return Inch;<br>}<br><br><br>// switching on a var=
iable of that type<br>SpacialUnit unit;<br>switch (unit) {<br>=C2=A0 =C2=A0=
 case Inch: break;<br>=C2=A0 =C2=A0 case Millimeter: break;<br>}<br><br><br=
>// passing as a constexpr value to a template that declares argument type<=
br>template &lt;SpacialUnit unit&gt;<br>class Rectangle {<br>=C2=A0 =C2=A0 =
....<br>};<br><br>Rectangle&lt;Inch&gt; saeRect;<br><br></span></div></code>=
</div><br>In every single one of those cases mentioned above, there is no o=
ther possible value besides a member of the enum that can be accepted witho=
ut explicit casting.</div><div>So why should we be required to qualify the =
enum name in these cases?</div></div>

<p></p>

-- <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>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/f2442186-7637-487d-ba01-919b6ef9f3e7%=
40isocpp.org?utm_medium=3Demail&amp;utm_source=3Dfooter" target=3D"_blank">=
https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/f2442186-7637-=
487d-ba01-919b6ef9f3e7%40isocpp.org</a>.<br>
</blockquote></div>

<p></p>

-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CAANG%3DkXAZbiVoBQMQZd2g1nbVnk%2BFnYM=
etjrNcEwpS3Pph4SBQ%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter"=
>https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAANG%3DkXAZb=
iVoBQMQZd2g1nbVnk%2BFnYMetjrNcEwpS3Pph4SBQ%40mail.gmail.com</a>.<br />

--000000000000ed10bd0582cd1890--

.
