220 31755 <470f86cc-36b7-4244-82dd-b795af107996@isocpp.org> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Nicol Bolas <jmckesson@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Allow constexpr static data members in a literal type.
Date: Sun, 26 Mar 2017 07:35:44 -0700 (PDT)
Lines: 118
Approved: news@gmane.org
Message-ID: <470f86cc-36b7-4244-82dd-b795af107996@isocpp.org>
References: <dfb9f65c-ea1d-e92b-85e0-333efed1aec5@scylladb.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_4619_1018717613.1490538944376"
X-Trace: blaine.gmane.org 1490538948 26272 195.159.176.226 (26 Mar 2017 14:35:48 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Sun, 26 Mar 2017 14:35:48 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBCEKFTV6ZUMBBQFD37DAKGQEXM34PNI@isocpp.org Sun Mar 26 16:35:42 2017
Return-path: <std-proposals+bncBCEKFTV6ZUMBBQFD37DAKGQEXM34PNI@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-pg0-f72.google.com ([74.125.83.72])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCEKFTV6ZUMBBQFD37DAKGQEXM34PNI@isocpp.org>)
	id 1cs9Gd-0005yw-VI
	for gclcip-std-proposals@m.gmane.org; Sun, 26 Mar 2017 16:35:40 +0200
Original-Received: by mail-pg0-f72.google.com with SMTP id v21sf29796233pgo.22
        for <gclcip-std-proposals@m.gmane.org>; Sun, 26 Mar 2017 07:35:46 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=date:from:to:message-id:in-reply-to:references:subject:mime-version
         :x-original-sender:reply-to:precedence:mailing-list:list-id
         :x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=sQSEvGWzGSBR18IO+5hhMdq7I1iDfnkOgQ0zeRfcfws=;
        b=yShUvEbjiER1nn7FFm+yXvkLvyih1y9NhwagYjoqdT1cUCc7k+sHGoZTtMXS8Ngjfq
         qeYjpAapeARvYk2bUTwF2b/YJBOoLiTnJvy2epG9uS0XHVipXUomx08c8D7fXn0lyf+r
         YZD8WsG5Qqn+qNBE5KZKFor//wIapEOkQWbSiVqlmuC3W7bNE4lsje7GJlTu6ISdP5f4
         XE4IaICai6G/cVTV/XJwR5TRd+nkrDhdc0Ywy4xrfgqaAtO+jCJzj7yseggou4bT1tHO
         9oJG2IbIxlQWUupe4Ckqv3Jn4ri1ulr/roRaJSd73ZD3ux60Z8CGj6rhUi0FYhEHsLhJ
         2SLw==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20161025;
        h=date:from:to:message-id:in-reply-to:references:subject:mime-version
         :x-original-sender:reply-to:precedence:mailing-list:list-id
         :x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=sQSEvGWzGSBR18IO+5hhMdq7I1iDfnkOgQ0zeRfcfws=;
        b=nubiXzAbaQxURO7AtbT5o6TOS/1/H6E8zfq4Q7mkDPUFKyJyLc1lld8rH4lnG19Fs2
         cfkKAsFpLlhnuLnO3miifvrMSMyMWF3hNgiuuGhIJmXKVKs8JiJnaRLB2wXQsHfpAiKX
         JCoJ4lyKVuqVRsaXxnA83GbkfAKzJxSkkDdDRwYaPX0Tz+Xw9otfFOXTHAMt7w+JwvqM
         hf7OFJFU46holQYl0BvCJ70Di64vXlVQnREAkbOK2FoLLr8XQSOqR3gNYlLd0zcJbKcJ
         KIlUQ1gQqTu4o7DSh1oZGcHYI/cZ0bYX256WprR5uneBDmrIvAxY3NWBUsd4LdI17k9h
         1tRw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:date:from:to:message-id:in-reply-to:references
         :subject:mime-version:x-original-sender:reply-to:precedence
         :mailing-list:list-id:x-spam-checked-in-group:list-post:list-help
         :list-archive:list-subscribe:list-unsubscribe;
        bh=sQSEvGWzGSBR18IO+5hhMdq7I1iDfnkOgQ0zeRfcfws=;
        b=B+XrJRV5B6IrodPmAuXOX3XC0xuLhduFotsT8xR956aWnIxre9/3tOwKGThwXil1hI
         iWoU7DTBWCKXpvKps0z8B18kVb03gHTORl3jYtEYwdKBT430ErKyPYyT6QFSBQhvmF7q
         03zkUwyi73oETxddrny+J/PrzMWxcCpBConP4J2tb2UcYlTSxI84wU509zkqZcmffazv
         6yQGtzNYQfjNMN2WjGzSa4TX+42ZPoYS3/EIVPe1vxahTu92O7wprN0O18AavVWLYcPh
         Zkzv/bxi/fisCT9zhHM9eYNOr7iFUWYg1YZ5L5HZjN2mWnF4Beg2OfzjWLQUx2ggTR2O
         hiSQ==
X-Gm-Message-State: AFeK/H1PijJbL+3xMcQT4p7ie5eKBBuuPZEQndt//91EdZp6Ddb03eCNgrtVNaz/7nPBiw==
X-Received: by 10.99.124.27 with SMTP id x27mr6301880pgc.50.1490538945623;
        Sun, 26 Mar 2017 07:35:45 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.157.47.171 with SMTP id r40ls1068205otb.0.gmail; Sun, 26 Mar
 2017 07:35:44 -0700 (PDT)
X-Received: by 10.157.11.150 with SMTP id 22mr235830oth.18.1490538944826;
        Sun, 26 Mar 2017 07:35:44 -0700 (PDT)
In-Reply-To: <dfb9f65c-ea1d-e92b-85e0-333efed1aec5@scylladb.com>
X-Original-Sender: jmckesson@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:31755
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/31755>

------=_Part_4619_1018717613.1490538944376
Content-Type: multipart/alternative; 
	boundary="----=_Part_4620_1380570845.1490538944376"

------=_Part_4620_1380570845.1490538944376
Content-Type: text/plain; charset=UTF-8

On Sunday, March 26, 2017 at 10:30:29 AM UTC-4, Avi Kivity wrote:
>
> Consider this type-safe bool class: 
>
>
>    template <typename Tag> 
>
>    class bool_class { 
>
>        bool _value; 
>
>    public: 
>
>        explicit constexpr bool_class(bool v) noexcept : _value(v) {} 
>
>        // more emulation of bool 
>
>        static constexpr bool_class yes = bool_class{true}; 
>
>        static constexpr bool_class no = bool_class{true}; 
>
>    }; 
>
>
> Compilation fails, I believe rightly, on clang, because by the time yes 
> and no are parsed, bool_class is an incomplete type, and therefore not a 
> literal type.  It could be worked around by making yes and no functions. 
>
> Should we make this legal?  It seems reasonable for types to offer 
> constants scoped under their own name, and if they are literal types, 
> that these constants can be constexpr.
>

How does it seem reasonable to define variables of a type that has not yet 
been defined? What's wrong with defining them outside of the scope of the 
class?

-- 
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/470f86cc-36b7-4244-82dd-b795af107996%40isocpp.org.

------=_Part_4620_1380570845.1490538944376
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On Sunday, March 26, 2017 at 10:30:29 AM UTC-4, Avi Kivity=
 wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.=
8ex;border-left: 1px #ccc solid;padding-left: 1ex;">Consider this type-safe=
 bool class:
<br>
<br>
<br>=C2=A0 =C2=A0template &lt;typename Tag&gt;
<br>
<br>=C2=A0 =C2=A0class bool_class {
<br>
<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0bool _value;
<br>
<br>=C2=A0 =C2=A0public:
<br>
<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0explicit constexpr bool_class(bool v) noexce=
pt : _value(v) {}
<br>
<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0// more emulation of bool
<br>
<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0static constexpr bool_class yes =3D bool_cla=
ss{true};
<br>
<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0static constexpr bool_class no =3D bool_clas=
s{true};
<br>
<br>=C2=A0 =C2=A0};
<br>
<br>
<br>Compilation fails, I believe rightly, on clang, because by the time yes=
=20
<br>and no are parsed, bool_class is an incomplete type, and therefore not =
a=20
<br>literal type. =C2=A0It could be worked around by making yes and no func=
tions.
<br>
<br>Should we make this legal? =C2=A0It seems reasonable for types to offer=
=20
<br>constants scoped under their own name, and if they are literal types,=
=20
<br>that these constants can be constexpr.<br></blockquote><div><br>How doe=
s it seem reasonable to define variables of a type that has not yet been de=
fined? What&#39;s wrong with defining them outside of the scope of the clas=
s?<br></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">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/470f86cc-36b7-4244-82dd-b795af107996%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/470f86cc-36b7-4244-82dd-b795af107996=
%40isocpp.org</a>.<br />

------=_Part_4620_1380570845.1490538944376--

------=_Part_4619_1018717613.1490538944376--

.
