220 30815 <CANu6V4VcppVPV_SimT+wGTL9Cp=DxHRpQJvsECoRgy0fBYySrQ@mail.gmail.com> article
Path: news.gmane.org!.POSTED!not-for-mail
From: "'Johannes Schaub' via ISO C++ Standard - Future Proposals" <std-proposals@isocpp.org>
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, 7 Feb 2017 18:22:24 +0100
Lines: 68
Approved: news@gmane.org
Message-ID: <CANu6V4VcppVPV_SimT+wGTL9Cp=DxHRpQJvsECoRgy0fBYySrQ@mail.gmail.com>
References: <CAMmfjbP44DFNHwVogEBL+LHjRXrK2hOZH-5LQLgVDmK=JSoqcg@mail.gmail.com>
 <5899F95E.8060407@gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
X-Trace: blaine.gmane.org 1486488148 1312 195.159.176.226 (7 Feb 2017 17:22:28 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Tue, 7 Feb 2017 17:22:28 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCQPNCEZSQNBBUME5DCAKGQEIT53PSQ@isocpp.org Tue Feb 07 18:22:23 2017
Return-path: <std-proposals+bncBCQPNCEZSQNBBUME5DCAKGQEIT53PSQ@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-io0-f197.google.com ([209.85.223.197])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCQPNCEZSQNBBUME5DCAKGQEIT53PSQ@isocpp.org>)
	id 1cb9TA-0008OP-Ha
	for gclcip-std-proposals@m.gmane.org; Tue, 07 Feb 2017 18:22:20 +0100
Original-Received: by mail-io0-f197.google.com with SMTP id 67sf118454203ioh.1
        for <gclcip-std-proposals@m.gmane.org>; Tue, 07 Feb 2017 09:22:26 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=mime-version:in-reply-to:references: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=ew3lkzN1XqH7/fQS6IC4thJ0nApFsGcMzef52IzEWLQ=;
        b=kR+19uhhuRo1NFIpYf9ILRhK6DwBsGdt3D8o2D2VeQJNCtmgnpe1jClOJX7CgumGkF
         BFa2I/3IHObbwu4584YBTz62lIzNHFknmYc0rpuj+W754CYWmOvqpWULlMk8vzT+FTUj
         lARHodh71MP5RTWeAi8CCMf/xdhHkL+vX8XNeVHdg1dXK5utQOPeja/cpZRzi+2AHMe3
         R/flhCNqlg4VXpCwGRjkE0DmDdmK48nXrcgwIVpvycT1RT5ce+fJJnEsrVxi2IkIvrPp
         IBp+ATi6B46o3DOalat7eB/vFxMpP5ZzWDPAijvBJ/R96txy5KryTYCSXoQPoqZ7geyp
         W+CA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:mime-version:in-reply-to:references: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=ew3lkzN1XqH7/fQS6IC4thJ0nApFsGcMzef52IzEWLQ=;
        b=bM+PP6EitwDC9cF3PkE+PJQ2OaaO4sr9oQ08gTE8rZQfk4PYUQffTSb2tw/Z+jkNY/
         1VhvQwvkghJ3bfwIdEz/T6KBAYIspZ2qd5wRE++cGaf/nU9udjSDSpEnC6wL02BeYB9E
         cQC5fwKwAUqsAYLtxZUmUIWy+q6zzXt9QZrI9ldtN+di7dV+zgdlgJC3JY3T+NY4sblh
         CysVl2I6lXWnzFZsl07X73Jk/wVC65XsXUfYT6jWtBi8NhdM3arJI8C1e8lnr4KCUs8o
         Wkn2YgrJ/sucDsCp3PJfNpIpZ5p0lCNwHggv5wiSu/D2Nd9s8/5L+/735gyeeJPiZ4cu
         44cw==
X-Gm-Message-State: AIkVDXIAktN/j3ys4F1cRSMmigOCHcdqcJ1GLBi5qhB1s5hZwGdn6IV0nKpxSQobQS15uw==
X-Received: by 10.36.127.71 with SMTP id r68mr3302452itc.11.1486488145795;
        Tue, 07 Feb 2017 09:22:25 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.157.45.3 with SMTP id v3ls15046258ota.44.gmail; Tue, 07 Feb
 2017 09:22:25 -0800 (PST)
X-Received: by 10.202.106.211 with SMTP id f202mr7332990oic.205.1486488145080;
        Tue, 07 Feb 2017 09:22:25 -0800 (PST)
Original-Received: from mail-ot0-x22b.google.com (mail-ot0-x22b.google.com. [2607:f8b0:4003:c0f::22b])
        by mx.google.com with ESMTPS id g10si1983227ote.47.2017.02.07.09.22.25
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Tue, 07 Feb 2017 09:22:25 -0800 (PST)
Received-SPF: pass (google.com: domain of schaub.johannes@googlemail.com designates 2607:f8b0:4003:c0f::22b as permitted sender) client-ip=2607:f8b0:4003:c0f::22b;
Original-Received: by mail-ot0-x22b.google.com with SMTP id 32so91341105oth.3
        for <std-proposals@isocpp.org>; Tue, 07 Feb 2017 09:22:25 -0800 (PST)
X-Received: by 10.157.40.139 with SMTP id s11mr9488055ota.226.1486488144583;
 Tue, 07 Feb 2017 09:22:24 -0800 (PST)
Original-Received: by 10.74.60.23 with HTTP; Tue, 7 Feb 2017 09:22:24 -0800 (PST)
In-Reply-To: <5899F95E.8060407@gmail.com>
X-Original-Sender: schaub.johannes@googlemail.com
X-Original-Authentication-Results: mx.google.com;       dkim=pass
 header.i=@googlemail.com;       spf=pass (google.com: domain of
 schaub.johannes@googlemail.com designates 2607:f8b0:4003:c0f::22b as
 permitted sender) smtp.mailfrom=schaub.johannes@googlemail.com;
       dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=googlemail.com
X-Original-From: Johannes Schaub <schaub.johannes@googlemail.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:30815
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/30815>

Alternatively, this can be merged with "strong typedefs", so that you
can type (warning: bikeshed)

    typedef new enum { A, B, C } X;

A new-type would depend on what it alias. Aliasing a new-type with an
enumeration type creates pretty much what currently a scoped
enumeration is, just as a "new" type without the
strongly-scoping-thing. Aliasing a new-type with a class type would be
ill-formed. Aliasing a new-type with an integer would create a new
integer type.. Aliasing an array type would apply the new-type
transformation onto the element type. Same for new-typing a pointer
type.


2017-02-07 17:44 GMT+01:00 Matthew Woehlke <mwoehlke.floss@gmail.com>:
> On 2017-02-07 01:12, Brian Bi wrote:
>> For example, should the following code be made well-formed?
>>
>> enum class Color {
>>     RED,
>>     GREEN,
>>     BLUE,
>> };
>>
>> Color color = RED;
>
> Not by itself, no. In general, *YES PLEASE*!
>
> My biggest hatred of strongly typed enums, and why I rarely use them, is
> that they conflated two orthogonal features: implicit conversion (i.e.
> that they *don't* implicitly convert), and scoping of the enumeration
> values.
>
> Fortunately, C++11 made it legal to name enumerators by their containing
> enumeration for both "classic" and "strongly typed" enumerations, which
> lessens the need for weakly-typed, strongly-scoped enumerations.
> However, there is as yet no good solution for strongly-typed,
> weakly-scoped enumerations, despite a fairly common desire for such
> critters.
>
> I'd like to see something like `using enum Color` to make the
> enumerators of a named enumeration available in a different scope.
>
> Note that this would not be *just* the parent scope. For example:
>
>   namespace zoo {
>     enum class Animal { Dog, Cat, Cow, Pig };
>   }
>   namespace farm { using enum ::zoo::Animal; }
>
>   auto x = farm::Dog; // okay; decltype(x) == ::zoo::Animal
>
> --
> 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.
> To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/5899F95E.8060407%40gmail.com.

-- 
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/CANu6V4VcppVPV_SimT%2BwGTL9Cp%3DDxHRpQJvsECoRgy0fBYySrQ%40mail.gmail.com.

.
