220 31761 <5262b75e-8281-411d-2248-6be37fd52b85@wanadoo.fr> article
Path: news.gmane.org!.POSTED!not-for-mail
From: "Vicente J. Botet Escriba" <vicente.botet@wanadoo.fr>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Allow constexpr static data members in a literal type.
Date: Sun, 26 Mar 2017 18:50:33 +0200
Lines: 69
Approved: news@gmane.org
Message-ID: <5262b75e-8281-411d-2248-6be37fd52b85@wanadoo.fr>
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: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: quoted-printable
X-Trace: blaine.gmane.org 1490547042 9110 195.159.176.226 (26 Mar 2017 16:50:42 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Sun, 26 Mar 2017 16:50:42 +0000 (UTC)
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:45.0)
 Gecko/20100101 Thunderbird/45.8.0
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDH67CONY4PBBW7C37DAKGQE33BII5A@isocpp.org Sun Mar 26 18:50:37 2017
Return-path: <std-proposals+bncBDH67CONY4PBBW7C37DAKGQE33BII5A@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-lf0-f70.google.com ([209.85.215.70])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBDH67CONY4PBBW7C37DAKGQE33BII5A@isocpp.org>)
	id 1csBN8-000185-Lf
	for gclcip-std-proposals@m.gmane.org; Sun, 26 Mar 2017 18:50:30 +0200
Original-Received: by mail-lf0-f70.google.com with SMTP id n78sf18675114lfi.4
        for <gclcip-std-proposals@m.gmane.org>; Sun, 26 Mar 2017 09:50:36 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=subject:to:references:from:message-id:date:user-agent:mime-version
         :in-reply-to:content-transfer-encoding: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=I38Vw0pufYJdKRO5bdYH5HJo1iwLtA3DMn923rc5crI=;
        b=Nauu4WENKl6PjzNYQXcS66Nzzf5t7Gq35aUefaJp6JCJ+xSpZDF8cbMysu8SjDzXC9
         UQ/sUUowKsWgwePmM+OFPK7f9vB5gr6YPNk8OwrIAD0BEsXXIyPihCce1rNsphFbbIpd
         gAHCD3YZXueeKmpM52SmQwlX4yh2D5d///WxjYgqox+nCdbaK8qP8sIOX12RSYTaKLyH
         LgoZeSEdgcHow9iqTofS4GjQDDc1UFbhgfWFqu5Vb91DfVlOLhq1CImTyymJrXryDNk1
         ygH8J+a9sc+SHqpAYI4idN8ihntfh/twuutttLg6n+HxaR7ygw2EO5oLOkKKd2PRCnHA
      
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:subject:to:references:from:message-id:date
         :user-agent:mime-version:in-reply-to:content-transfer-encoding
         :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=I38Vw0pufYJdKRO5bdYH5HJo1iwLtA3DMn923rc5crI=;
        b=AGJWcpyLHoLlQ3svwfnUL+XwEccF/8ijXoqK+MXfBFVE/X6YiGFr6DzKUK92UjKpkv
         i6d98SFptowu/g+o2GCkA9OwBXw+Hb6+pphjKHIUcJOMl90eAso0Otlg93eIz5KTLdnx
         xOaXCIysJR1XAkdvNBO5Czi3TDo1zEGVjpbVmjnl1Ba73t3riMlBSJyGzGnEa4DKJTDF
         JIWkFB822b0bQmvpma0nOzOdzaD0u/qT8P4I17YzIpF2fG9XjmeBYTqCNPVjzqvyGRa8
         YkJAnmACw3tSHLqK0y3zG7hkFoFXK49RTWe+O+tHvaUBVMw2d2Z9AxjytzSD7z0zkTOY
  
X-Gm-Message-State: AFeK/H2UQaXBkBMEIs9AVL6SSrFil4OzoYyECcFYezgddAMBVn6PVvcGducFA1D6bID9Yw==
X-Received: by 10.25.196.68 with SMTP id u65mr2295243lff.0.1490547036763;
        Sun, 26 Mar 2017 09:50:36 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.28.66.81 with SMTP id p78ls1003030wma.7.canary-gmail; Sun, 26
 Mar 2017 09:50:35 -0700 (PDT)
X-Received: by 10.28.86.68 with SMTP id k65mr6169994wmb.112.1490547035343;
        Sun, 26 Mar 2017 09:50:35 -0700 (PDT)
Original-Received: from smtp.smtpout.orange.fr (smtp03.smtpout.orange.fr. [80.12.242.125])
        by mx.google.com with ESMTPS id 188si11066761wme.151.2017.03.26.09.50.35
        for <std-proposals@isocpp.org>
        (version=TLS1 cipher=AES128-SHA bits=128/128);
        Sun, 26 Mar 2017 09:50:35 -0700 (PDT)
Received-SPF: neutral (google.com: 80.12.242.125 is neither permitted nor denied by best guess record for domain of vicente.botet@wanadoo.fr) client-ip=80.12.242.125;
Original-Received: from imac-de-vicente-botet-escriba.home ([2.11.188.167])
	by mwinf5d57 with ME
	id 0gqa1v0013d8Kde03gqaZT; Sun, 26 Mar 2017 18:50:35 +0200
X-ME-Helo: imac-de-vicente-botet-escriba.home
X-ME-Auth: dmljZW50ZS5ib3RldEB3YW5hZG9vLmZy
X-ME-Date: Sun, 26 Mar 2017 18:50:35 +0200
X-ME-IP: 2.11.188.167
In-Reply-To: <dfb9f65c-ea1d-e92b-85e0-333efed1aec5@scylladb.com>
X-Original-Sender: vicente.botet@wanadoo.fr
X-Original-Authentication-Results: mx.google.com;       spf=neutral
 (google.com: 80.12.242.125 is neither permitted nor denied by best guess
 record for domain of vicente.botet@wanadoo.fr) smtp.mailfrom=vicente.botet@wanadoo.fr
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:31761
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/31761>

Le 26/03/2017 =C3=A0 16:30, Avi Kivity a =C3=A9crit :
> 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 =3D bool_class{true};
>
>       static constexpr bool_class no =3D bool_class{true};
>
>   };
>
>
> Compilation fails, I believe rightly, on clang, because by the time=20
> yes and no are parsed, bool_class is an incomplete type, and therefore=20
> not a literal type.  It could be worked around by making yes and no=20
> functions.
>
> Should we make this legal?  It seems reasonable for types to offer=20
> constants scoped under their own name, and if they are literal types,=20
> that these constants can be constexpr.
>
It seems that you can do

   template <typename Tag>

   class bool_class {

       bool _value;

   public:

       explicit constexpr bool_class(bool v) noexcept : _value(v) {}

       // more emulation of bool

       static const bool_class yes;

       static const bool_class no;

   };

    constexpr bool_class bool_class::yes =3D bool_class{true};

    constexpr bool_class bool_class::no =3D bool_class{true};


Vicente

--=20
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 e=
mail 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/5262b75e-8281-411d-2248-6be37fd52b85%40wanadoo.f=
r.

.
