220 31759 <078635c1-3de8-458b-9df3-34f4c62db1fd@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: Re: Allow constexpr static data members in a
 literal type.
Date: Sun, 26 Mar 2017 08:22:32 -0700 (PDT)
Lines: 166
Approved: news@gmane.org
Message-ID: <078635c1-3de8-458b-9df3-34f4c62db1fd@isocpp.org>
References: <dfb9f65c-ea1d-e92b-85e0-333efed1aec5@scylladb.com>
 <470f86cc-36b7-4244-82dd-b795af107996@isocpp.org>
 <b9d7e28d-325b-b760-e021-ef087d0b56f3@scylladb.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_4926_1196441680.1490541753038"
X-Trace: blaine.gmane.org 1490541766 22780 195.159.176.226 (26 Mar 2017 15:22:46 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Sun, 26 Mar 2017 15:22:46 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBCEKFTV6ZUMBBONZ37DAKGQE42Z4X2I@isocpp.org Sun Mar 26 17:22:41 2017
Return-path: <std-proposals+bncBCEKFTV6ZUMBBONZ37DAKGQE42Z4X2I@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-oi0-f69.google.com ([209.85.218.69])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCEKFTV6ZUMBBONZ37DAKGQE42Z4X2I@isocpp.org>)
	id 1cs9zw-0004SK-PB
	for gclcip-std-proposals@m.gmane.org; Sun, 26 Mar 2017 17:22:28 +0200
Original-Received: by mail-oi0-f69.google.com with SMTP id f193sf30201099oib.1
        for <gclcip-std-proposals@m.gmane.org>; Sun, 26 Mar 2017 08:22:34 -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=BLEZ6G1mAkUpK8+5vvxQ96clKNAV1hp4Dw3pjPoVmMY=;
        b=SgVwjqgzrsK/vlc7B+C8d+8eHfdcSfHDjR9I4JyQ0OaCrFB9RhlVd4FtZ8z2ADfY9q
         7pnCxoE9E6OtXKHtaypgp3mpKlNEh73GNlmwTDMKaoJomyMcm22g2xdeW8qr/GHFPF68
         UpO96jVRnfPcWMsXZOgcUjjA3047/kVnz8dgG0MpV1uVOCELYAyXW/+1M00fz73ZGQ6U
         ylUEXNtnjkTRQ8nBL3d7YAEc9nYmDUbJNUFnnbALFtc/t4LGMkybytEunaJW3aoULPTn
         WoRLkjsFBo9UHPSGmt7Wox3MJrwbsmeym9WDm0SOV43Je+lLruMwQfx96T4UIna8bEVW
         IcHw==
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=BLEZ6G1mAkUpK8+5vvxQ96clKNAV1hp4Dw3pjPoVmMY=;
        b=MjaR3ogJAtFDiPElki2ojdCL4nFPioaMFZXJST34Lq6Z3WT5nV7PWq0JycicBBia0y
         BO+IetiG872I+YQL4XUhXDqUTL0RIJi0zO+OgdVU+jlWOGD7STV76cX99czTd9NjYIyw
         NJrYrUF+MCwtHEobgNWP0XophEegqDDkEKRSwxJ0L283QfVIAypOaQh5R0xEVc6fYJaF
         WrlTDPWomT60VRGEvCt6y+SJw7OJTUz8UyttzZRHEKZGQ8Df0Yfi8EVORl6MENUvwHV8
         Hc9PG5f4s/WWeYajn+M2g4cKi8lwywgAE1ZUVoqAkK4IVyOAxyaowUasVKUCStCWPjcw
         VHeQ==
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=BLEZ6G1mAkUpK8+5vvxQ96clKNAV1hp4Dw3pjPoVmMY=;
        b=MbxTw6AMrfLVYJnthyzj5J8HE6MxYlfGGiHKMA0liQeUjJiERUeF4Hm/N4uYgB4NNL
         5NB2DWJC/e5INSTh4XHIs6eRNfAc4FMjNqlQ3OOMC6qTdk5usvTyeJtWf0SJYpyZ2QyV
         FpV6bAcVTThsM1nLTwEIUVNMPbDmdJeOQvfwoHS6nyoX7efhPWEKCL1StM4Otem0Lb+l
         D9ewEZEykL7Na1+L+CXUOwS4lUj8nhV+e9GADryL3bFgDUGFHlkE7fZd9f1VbxVoYehQ
         Yxr4KJM3TciFBFzhBW6kNIw3Izj5D6Zfr0n7TMTkfAL/m/6mje6BtbNKUYGe6KyKsqMz
         dEtg==
X-Gm-Message-State: AFeK/H23wpykl1E9Ipu9lua9xGkR9vmdWAomGWHFoiFYwsHsXGNEWWbVF4rspFMRXTGeMA==
X-Received: by 10.157.80.33 with SMTP id a33mr6179237oth.92.1490541754391;
        Sun, 26 Mar 2017 08:22:34 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.157.35.124 with SMTP id k57ls4623146otd.41.gmail; Sun, 26 Mar
 2017 08:22:33 -0700 (PDT)
X-Received: by 10.157.32.10 with SMTP id n10mr1491173ota.10.1490541753479;
        Sun, 26 Mar 2017 08:22:33 -0700 (PDT)
In-Reply-To: <b9d7e28d-325b-b760-e021-ef087d0b56f3@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:31759
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/31759>

------=_Part_4926_1196441680.1490541753038
Content-Type: multipart/alternative; 
	boundary="----=_Part_4927_582499589.1490541753038"

------=_Part_4927_582499589.1490541753038
Content-Type: text/plain; charset=UTF-8



On Sunday, March 26, 2017 at 10:49:22 AM UTC-4, Avi Kivity wrote:
>
>
>
> On 03/26/2017 05:35 PM, Nicol Bolas wrote:
>
> 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? 
>
> You can do that already, within an inline member function.
>

That's not defining a variable. That's defining a function that returns a 
value of a certain type.

-- 
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/078635c1-3de8-458b-9df3-34f4c62db1fd%40isocpp.org.

------=_Part_4927_582499589.1490541753038
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><br>On Sunday, March 26, 2017 at 10:49:22 AM UTC-4, Av=
i Kivity wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-=
left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">
 =20
   =20
 =20
  <div bgcolor=3D"#FFFFFF" text=3D"#000000">
    <p><br>
    </p>
    <br>
    <div>On 03/26/2017 05:35 PM, Nicol Bolas
      wrote:<br>
    </div>
    <blockquote type=3D"cite">
      <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.8=
ex;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) =
noexcept :
          _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 bo=
ol_class{true};
          <br>
          <br>
          =C2=A0 =C2=A0 =C2=A0 =C2=A0static constexpr bool_class no =3D boo=
l_class{true};
          <br>
          <br>
          =C2=A0 =C2=A0};
          <br>
          <br>
          <br>
          Compilation fails, I believe rightly, on clang, because by the
          time yes <br>
          and no are parsed, bool_class is an incomplete type, and
          therefore not a <br>
          literal type. =C2=A0It could be worked around by making yes and n=
o
          functions.
          <br>
          <br>
          Should we make this legal? =C2=A0It seems reasonable for types to
          offer <br>
          constants scoped under their own name, and if they are literal
          types, <br>
          that these constants can be constexpr.<br>
        </blockquote>
        <div><br>
          How does it seem reasonable to define variables of a type that
          has not yet been defined? </div>
      </div>
    </blockquote>
   =20
    You can do that already, within an inline member function.<br></div></b=
lockquote><div><br>That&#39;s not defining a variable. That&#39;s defining =
a function that returns a value of a certain type.</div><br></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/078635c1-3de8-458b-9df3-34f4c62db1fd%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/078635c1-3de8-458b-9df3-34f4c62db1fd=
%40isocpp.org</a>.<br />

------=_Part_4927_582499589.1490541753038--

------=_Part_4926_1196441680.1490541753038--

.
