220 27796 <a4dd84d3-45b6-4c0e-a1cc-6c88c46cbe35@isocpp.org> article
Path: news.gmane.org!.POSTED!not-for-mail
From: rhalbersma@gmail.com
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: if constexpr in class declaration
Date: Wed, 17 Aug 2016 02:44:05 -0700 (PDT)
Lines: 134
Approved: news@gmane.org
Message-ID: <a4dd84d3-45b6-4c0e-a1cc-6c88c46cbe35@isocpp.org>
References: <b802b9e3-9f14-4b93-afb5-47b5dc5034a1@isocpp.org>
 <CAOfiQq=6+9_qGF-EEHjJ_bpt993s0amWHwoE=WABHXCCu+xc5Q@mail.gmail.com> <6322c6eb-76f7-47cc-b012-db8c5d8892fc@isocpp.org>
 <CAOfiQqm4afYf5Wkk1EBTRQuNsPAo7FpYMx_k6FyuXfEhSwOVrg@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_369_2061463580.1471427045606"
X-Trace: blaine.gmane.org 1471427054 22990 195.159.176.226 (17 Aug 2016 09:44:14 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Wed, 17 Aug 2016 09:44:14 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBCMYZKMJV4IRBZXD2C6QKGQENUUYIKA@isocpp.org Wed Aug 17 11:44:10 2016
Return-path: <std-proposals+bncBCMYZKMJV4IRBZXD2C6QKGQENUUYIKA@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-qk0-f197.google.com ([209.85.220.197])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCMYZKMJV4IRBZXD2C6QKGQENUUYIKA@isocpp.org>)
	id 1bZxOL-0005gp-Rk
	for gclcip-std-proposals@m.gmane.org; Wed, 17 Aug 2016 11:44:10 +0200
Original-Received: by mail-qk0-f197.google.com with SMTP id i140sf225694196qke.0
        for <gclcip-std-proposals@m.gmane.org>; Wed, 17 Aug 2016 02:44:10 -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=BvsQ90vZIZNrp7w0nP/4nlob6vHHvSiQfwK2jQe5wu0=;
        b=0xd3OV2HurFB2jDiwJUzNnPrYPpndaDqLMEBFc/EKfS8cCRTGKwWfNC1hObEi3Cy1Q
         xWFEElRSqp3WOHKWUx6RAg/4qOEs+UsweyMFZhleTvN65xgrH5Sp7uI2lhd/F7VArzXn
         eLZFzUcCLN9D99zcWiT038o8fIWCHVTKXphy/QJG+q0QlV9rfMhaRZYgZ3iJyav36HbL
         /ex2DU/5WywqXp6yEpESLqzywz/hdmWnEiwUavkySTC4jDqYgPmVB6kUl8fO/FtBVPds
         +XqslV9b7zd8Xre4/g4XhoBXZWUkbInMllW4ij9FwGMkKCZODGC3Kbn15u8YMY+44KXP
         8NKg==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        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=BvsQ90vZIZNrp7w0nP/4nlob6vHHvSiQfwK2jQe5wu0=;
        b=Rwf2Nlk/BSmn7vLq8s1p7XAsm4pSJmOI/T7tIbOsHioyocF9rTF6oNrusSTK0F9I8L
         9qhQGN+OBIDvYjJjzoGQYiz8J4+uVGS9hDB9X3Wi4faK3zdEDNK8WTlPg50RL713KZkO
         JTIppfZW3W+GouDnvFyOcAw8S4V81vrbh1vSxp8DKcxYDNqjIxgX7pfwSifLw7p4BoPh
         o8Sm7RCuwqEVxQUy5DjSWQqVL4sn7orgcQ6dKHW2/9alUPt6YLGNamdbmHQLmZxRhzn8
         lAriOYEj4MUjH/LEw4Cj1rDynvfCRbvLiiIPC8n9X3maaKluixOnycy3o+zxc+N44sHV
         neGQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        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=BvsQ90vZIZNrp7w0nP/4nlob6vHHvSiQfwK2jQe5wu0=;
        b=QWzAa6MZsenIL6fpEeS0uOA+4Teg76pED3Amf6nBV6LkGMQe/9Ucv+7nCptluLu7A6
         pnUzBRXBtTR5ar5RCfwn4uFWA+nSn8ScD2BvqGKUntS7FNJPxygJ0/zGSDAAnOZKmdOU
         yEcbKTPiuxmRBt90HPqmOOiaP3mbPBaeaCnhiwObGniXAW3hlthGrHjbaRbsdz6PHjbm
         hUMZvOImzxn296L29RP5YVpf6lYF28wK9hHASXApxQsU8DdKIAMirCEtR344Arekfnu4
         tsX0USv5vAHKYTQlK5cFdEWZg0mlCQ1NcB6S35VF5b92SvAi3535iTa3y1y8ym+sW9ID
         W1yw==
X-Gm-Message-State: AEkoousneTdLAPXY+SZ0nVMhBBim+zlA2GFaPIBkS31uw+i5Suf3pW/z6wMjjJJbRDhK0g==
X-Received: by 10.200.56.115 with SMTP id r48mr28275196qtb.28.1471427050136;
        Wed, 17 Aug 2016 02:44:10 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.107.55.214 with SMTP id e205ls558633ioa.11.gmail; Wed, 17 Aug
 2016 02:44:06 -0700 (PDT)
X-Received: by 10.36.103.4 with SMTP id u4mr374975itc.9.1471427046612;
        Wed, 17 Aug 2016 02:44:06 -0700 (PDT)
In-Reply-To: <CAOfiQqm4afYf5Wkk1EBTRQuNsPAo7FpYMx_k6FyuXfEhSwOVrg@mail.gmail.com>
X-Original-Sender: rhalbersma@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:27796
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/27796>

------=_Part_369_2061463580.1471427045606
Content-Type: multipart/alternative; 
	boundary="----=_Part_370_2018173270.1471427045607"

------=_Part_370_2018173270.1471427045607
Content-Type: text/plain; charset=UTF-8



On Wednesday, August 10, 2016 at 1:12:16 AM UTC+2, Richard Smith wrote:
>
> On Tue, Aug 9, 2016 at 3:01 PM, <rhalb...@gmail.com <javascript:>> wrote:
>
>>
>>
>> On Tuesday, August 9, 2016 at 7:56:22 PM UTC+2, Richard Smith wrote:
>>>
>>>
>>> Yes, it's been thought about, but this is doing something fundamentally 
>>> different from what 'if constexpr' does, and it has major practical 
>>> problems. You can look through the history of papers on constexpr if and 
>>> static if for a taste of the problems.
>>>
>>
>> I understand that applying if-constexpr to conditional data member layout 
>> is different because a regular if cannot appear at class scope. But reading 
>> the static if papers and their critiques, the supplied alternative to the 
>> OP's example using partial specializations, tuple and empty base class 
>> trickery do not really provide a superior alternative. Optimal class layout 
>> is currently cumbersome, using if-constexpr would make this a lot easier 
>> for users. 
>>
>> What exactly would be making it hard (compared to if-constexpr at 
>> function scope) for the compiler to do the conditional data layout using 
>> if-constexpr?
>>
>
> Just a taste:
>
> int value;
> template<typename T> struct X {
>   some_kind_of_static_if (is_fooable_v<T>) {
>     T value;
>   }
>   int f() { return value; }
> };
>

How is that different from

int value;

template<typename T> int f()
{
    some_kind_of_static_if(is_fooable_v<T>) {
        return value;
    } else {
        int value = 42;
        return value;
   }
} 

Won't there be a warning about shadowing a global variable in both 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/a4dd84d3-45b6-4c0e-a1cc-6c88c46cbe35%40isocpp.org.

------=_Part_370_2018173270.1471427045607
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><br>On Wednesday, August 10, 2016 at 1:12:16 AM UTC+2,=
 Richard Smith wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;m=
argin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=
=3D"ltr"><div><div class=3D"gmail_quote">On Tue, Aug 9, 2016 at 3:01 PM,  <=
span dir=3D"ltr">&lt;<a href=3D"javascript:" target=3D"_blank" gdf-obfuscat=
ed-mailto=3D"NsENg_U9CQAJ" rel=3D"nofollow" onmousedown=3D"this.href=3D&#39=
;javascript:&#39;;return true;" onclick=3D"this.href=3D&#39;javascript:&#39=
;;return true;">rhalb...@gmail.com</a>&gt;</span> wrote:<br><blockquote cla=
ss=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;pa=
dding-left:1ex"><div dir=3D"ltr"><span><br><br>On Tuesday, August 9, 2016 a=
t 7:56:22 PM UTC+2, Richard Smith wrote:<blockquote class=3D"gmail_quote" s=
tyle=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:=
1ex"><div dir=3D"ltr"><div class=3D"gmail_quote"><div><br></div><div>Yes, i=
t&#39;s been thought about, but this is doing something fundamentally diffe=
rent from what &#39;if constexpr&#39; does, and it has major practical prob=
lems. You can look through the history of papers on constexpr if and static=
 if for a taste of the problems.</div></div></div></blockquote><div><br></d=
iv></span><div>I understand that applying if-constexpr to conditional data =
member layout is different because a regular if cannot appear at class scop=
e. But reading the static if papers and their critiques, the supplied alter=
native to the OP&#39;s example using partial specializations, tuple and emp=
ty base class trickery do not really provide a superior alternative. Optima=
l class layout is currently cumbersome, using if-constexpr would make this =
a lot easier for users.=C2=A0</div><div><br></div><div>What exactly would b=
e making it hard (compared to if-constexpr at function scope) for the compi=
ler to do the conditional data layout using if-constexpr?</div></div></bloc=
kquote><div><br></div><div>Just a taste:</div><div><br></div><div>int value=
;</div><div>template&lt;typename T&gt; struct X {</div><div>=C2=A0 some_kin=
d_of_static_if (is_fooable_v&lt;T&gt;) {</div><div>=C2=A0 =C2=A0 T value;</=
div><div>=C2=A0 }</div><div>=C2=A0 int f() { return value; }</div><div>};</=
div></div></div></div></blockquote><div><br></div><div>How is that differen=
t from</div><div><br></div><div>int value;</div><div><br></div><div>templat=
e&lt;typename T&gt; int f()</div><div>{</div><div>=C2=A0 =C2=A0 some_kind_o=
f_static_if(is_fooable_v&lt;T&gt;) {</div><div>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =
return value;</div><div>=C2=A0 =C2=A0 } else {</div><div>=C2=A0 =C2=A0 =C2=
=A0 =C2=A0 int value =3D 42;</div><div>=C2=A0 =C2=A0 =C2=A0 =C2=A0 return v=
alue;</div><div>=C2=A0 =C2=A0}</div><div>}=C2=A0</div><div><br></div><div>W=
on&#39;t there be a warning about shadowing a global variable in both 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">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/a4dd84d3-45b6-4c0e-a1cc-6c88c46cbe35%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/a4dd84d3-45b6-4c0e-a1cc-6c88c46cbe35=
%40isocpp.org</a>.<br />

------=_Part_370_2018173270.1471427045607--

------=_Part_369_2061463580.1471427045606--

.
