220 32541 <99350a9e-0c6b-468d-9761-f2b2b052275e@isocpp.org> article
Path: news.gmane.org!.POSTED!not-for-mail
From: ma.kalbfuss@web.de
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: relaxing rules for ternary operator. Allow
 incompatible types.
Date: Sun, 21 May 2017 02:03:45 -0700 (PDT)
Lines: 424
Approved: news@gmane.org
Message-ID: <99350a9e-0c6b-468d-9761-f2b2b052275e@isocpp.org>
References: <1b5ee8eb-53df-4e98-af2f-829c7bc2e5b2@isocpp.org>
 <9064929.QEV8q21eIZ@tjmaciei-mobl1>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_2043_190528582.1495357425403"
X-Trace: blaine.gmane.org 1495357427 24836 195.159.176.226 (21 May 2017 09:03:47 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Sun, 21 May 2017 09:03:47 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBC7YTI72XQOBB4VPQXEQKGQEDUYWU4A@isocpp.org Sun May 21 11:03:42 2017
Return-path: <std-proposals+bncBC7YTI72XQOBB4VPQXEQKGQEDUYWU4A@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-yw0-f198.google.com ([209.85.161.198])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBC7YTI72XQOBB4VPQXEQKGQEDUYWU4A@isocpp.org>)
	id 1dCMm5-0006KS-Tt
	for gclcip-std-proposals@m.gmane.org; Sun, 21 May 2017 11:03:42 +0200
Original-Received: by mail-yw0-f198.google.com with SMTP id f204sf61022531ywc.15
        for <gclcip-std-proposals@m.gmane.org>; Sun, 21 May 2017 02:03:47 -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=PiVZBObZnayN+xHPJo/ouOr/EC5xWTXTT8b4/bajfQI=;
        b=uTkhZWFi5ECmv4Q19xWZWm2HSJwtkhfxySXXYISKr5xU2zzbp8Tg1p6nppyJoqyat0
         tKOow2zU9FZu021QyJR9mbbSNZbLhk4Cwdtl72ls4Ms9eskVa7cBF8UjHbHZE5wwJPv0
         44QmI+gi+1cXGzRIqLa93uB/u/DmkIbJV/g/s1hZQxV8SmGeuTMzakMIkYNDPmwcwFie
         bEs1Bixv9qVMEXka3nl3MKWlToRv3YRGiW/x4GcKxCHNGGIUkrQ9bSxh2c1SCvsqRsqG
         PHMYIf4gbG6WWeKEipu+8tSFJ7qlYOxlSU68HlTjryFZv786B9HbaWLR812YRGmwddMQ
         W3/Q==
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=PiVZBObZnayN+xHPJo/ouOr/EC5xWTXTT8b4/bajfQI=;
        b=GZdp21mCwLimqqH03IHRprM6UC7xadUNMQF3oL5g2E4L1tN8SaLbixYT9UJ9n5TKp7
         5n7blU5k9cV5F8jH0FUcpHjU1lSckCBx38VXZf1xvNGF9ws80Y7b7PALEvzqToZu/5al
         8Wsx/pCeGjT43nIe0QEWenrXWlk/m1RJVTyk8P/F6kRHmeJ+yGqHJGD9T9m2MUJOBb0W
         dU+AqTuh3mQPeGOoynv3dE9WcIZtqR1AYwLglaZIT9J5FV6EY8xupdscmaCJcyqNRozr
         rn5IOgDfvh75DxfHc4SF3rMxPh4qNtLxskKoVM0rJc5ZbE+Y2TMj2PeqZA5GcDyyFw+O
         N4Rw==
X-Gm-Message-State: AODbwcBqvOmFj7fkeeewxkaDRL5XaGpRkf0ZSoLcHj5JdiFhdSA0qoCe
	FHvC8VKWOCyqynD5
X-Received: by 10.129.38.213 with SMTP id m204mr8751750ywm.114.1495357426954;
        Sun, 21 May 2017 02:03:46 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.157.11.145 with SMTP id 17ls1982024oth.36.gmail; Sun, 21 May
 2017 02:03:46 -0700 (PDT)
X-Received: by 10.157.13.170 with SMTP id 39mr370469ots.18.1495357426099;
        Sun, 21 May 2017 02:03:46 -0700 (PDT)
In-Reply-To: <9064929.QEV8q21eIZ@tjmaciei-mobl1>
X-Original-Sender: ma.kalbfuss@web.de
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:32541
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/32541>

------=_Part_2043_190528582.1495357425403
Content-Type: multipart/alternative; 
	boundary="----=_Part_2044_681404285.1495357425404"

------=_Part_2044_681404285.1495357425404
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

I revisited your statement, that this isn't possible, because the type=20
would be determined at runtime. I have to disagree, now.  It is possible at=
=20
compile time.

Look at the following code:

auto x =3D runtime_condition ? A{} : B{};
x.doit();

This is not going to work, as you stated. But you could write the following=
=20
instead:

auto f =3D [&](auto x) { x.doit(); };
runtime_condition ? f(A{}) : f(B{});

The code, following the ternary statement is moved into a generic lambda.
auto x =3D runtime_condition ? A{} : B{};

The generic lambda is instantiated two times, for each branch. Depending on=
=20
runtime_condition,
only one instance is executed. The statement

auto x =3D runtime_condition ? A{} : X{};

could introduce the following code inside the current scope twice, like the=
=20
generic lambda did. Ones for each type.
Depending on the runtime_condition, the code pointer is moved to the first=
=20
or the second instantiaton with a jump.

The following C++ code snippet describes roughly how the generated code=20
could look like.

#include <iostream>

struct A{ void doit(){ std::cout << "A::doit" << std::endl; } };
struct B{ void doit(){ std::cout << "B::doit" << std::endl; } };

int main()
{
    auto runtime_condition =3D true;

    if(runtime_condition)
        goto ternary_branch_1;
    else
        goto ternary_branch_2;

ternary_branch_1:
    A __instance1__;
    __instance1__.doit();
    return 0;
ternary_branch_2:
    B __instance2__;
    __instance2__.doit();
    return 0;
}







Am Samstag, 20. Mai 2017 21:29:56 UTC+2 schrieb Thiago Macieira:
>
> On s=C3=A1bado, 20 de maio de 2017 10:41:56 PDT ma.ka...@web.de <javascri=
pt:>=20
> wrote:=20
> > Hi Guys,=20
> >=20
> > I had the following situation:=20
> >=20
> > I have a Group of StaticSet classes with a compatible interface but=20
> > distinct in there concrete type. empty_set is not an intervall!=20
> > I tried the following:=20
> >=20
> >=20
> > auto dec_digit =3D make_interval('0', '0' + std::min(base, DECIMAL_BASE=
) -=20
> 1);=20
> > auto upper_digit =3D (base > DECIMAL_DIGIT) ? make_interval('A', 'A' +=
=20
> (base=20
> > - 1 - DECIMAL_BASE)) : empty_set;=20
> > auto lower_digit =3D (base > DECIMAL_DIGIT) ? make_interval('a', 'a' +=
=20
> (base=20
> > - 1 - DECIMAL_BASE)) : empty_set;=20
> >=20
> >=20
> > Wouldn't it be possible to allow such code, especially in conjunction=
=20
> with=20
> > concepts?=20
>
> No. lower_digit must have exactly one type, determined at compile-time.=
=20
> What=20
> you're asking for would cause the type to be determined at runtime, which=
=20
> is=20
> not possible in C++.=20
>
> Alternatives:=20
> * convert empty_set to make_interval's type=20
> * convert either to a common type (which you need to be explicit about, s=
o=20
> it=20
>    won't work with auto)=20
> * use std::variant<interval, decltype(empty_set)>=20
>
> --=20
> Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org=20
>    Software Architect - Intel Open Source Technology Center=20
>
>

--=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/99350a9e-0c6b-468d-9761-f2b2b052275e%40isocpp.or=
g.

------=_Part_2044_681404285.1495357425404
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">I revisited your statement, that this isn&#39;t possible, =
because the type would be determined at runtime. I have to disagree, now.=
=C2=A0 It is possible at compile time.<br><br>Look at the following code:<b=
r><br><div style=3D"background-color: rgb(250, 250, 250); border-color: rgb=
(187, 187, 187); border-style: solid; border-width: 1px; overflow-wrap: bre=
ak-word;" class=3D"prettyprint"><code class=3D"prettyprint"><div class=3D"s=
ubprettyprint"><span style=3D"color: #008;" class=3D"styled-by-prettify">au=
to</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> x </spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify"> runtime_condition </s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">?</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify"> A</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">{}</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;"=
 class=3D"styled-by-prettify">:</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"> B</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">{};</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"><br>x</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>.</span><span style=3D"color: #000;" class=3D"styled-by-prettify">doit</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">();</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"><br></span></div></co=
de></div><br>This is not going to work, as you stated. But you could write =
the following instead:<br><br><div style=3D"background-color: rgb(250, 250,=
 250); border-color: rgb(187, 187, 187); border-style: solid; border-width:=
 1px; overflow-wrap: break-word;" class=3D"prettyprint"><code class=3D"pret=
typrint"><div class=3D"subprettyprint"><span style=3D"color: #008;" class=
=3D"styled-by-prettify">auto</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> f </span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">[&amp=
;](</span><span style=3D"color: #008;" class=3D"styled-by-prettify">auto</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> x</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">)</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">{</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"> x</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">.</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify">doit</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">();</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">};</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"><br>runtime_condit=
ion </span><span style=3D"color: #660;" class=3D"styled-by-prettify">?</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> f</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify">A</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">{})</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">:</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> f</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">B</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">{});</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"><br></span></div></code=
></div><br>The code, following the ternary statement is moved into a generi=
c lambda.<br><code class=3D"prettyprint"><div style=3D"background-color: rg=
b(250, 250, 250); border-color: rgb(187, 187, 187); border-style: solid; bo=
rder-width: 1px; overflow-wrap: break-word;" class=3D"prettyprint"><code cl=
ass=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"color: #00=
8;" class=3D"styled-by-prettify">auto</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> x </span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">=3D</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"> runtime_condition </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">?</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> A</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">{}</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">:</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> B</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">{};</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"><br></span></div></code></div><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"><br>The generic lambd=
a is instantiated two times, for each branch. Depending on runtime_conditio=
n,<br>only one instance is executed. The statement<br></span></code><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"></span><br><span style=
=3D"color: #000;" class=3D"styled-by-prettify"></span><code class=3D"pretty=
print"><span style=3D"color: #000;" class=3D"styled-by-prettify"><div style=
=3D"background-color: rgb(250, 250, 250); border-color: rgb(187, 187, 187);=
 border-style: solid; border-width: 1px; overflow-wrap: break-word;" class=
=3D"prettyprint"><code class=3D"prettyprint"><div class=3D"subprettyprint">=
<span style=3D"color: #008;" class=3D"styled-by-prettify">auto</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> x </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> runtime_condition </span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">?</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> A</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">{}</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">:</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> X</span><span style=3D"color: #660;" class=3D"styled-by-prettify">{}=
;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></spa=
n></div></code></div><br>could introduce the following code inside the curr=
ent scope twice, like the generic lambda did. Ones for each type.<br>Depend=
ing on the runtime_condition, the code pointer is moved to the first or the=
 second instantiaton with a jump.<br><br></span></code>The following C++ co=
de snippet describes roughly how the generated code could look like.<br><br=
><div style=3D"background-color: rgb(250, 250, 250); border-color: rgb(187,=
 187, 187); border-style: solid; border-width: 1px; overflow-wrap: break-wo=
rd;" class=3D"prettyprint"><code class=3D"prettyprint"><div class=3D"subpre=
ttyprint"><span style=3D"color: #800;" class=3D"styled-by-prettify">#includ=
e</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><=
span style=3D"color: #080;" class=3D"styled-by-prettify">&lt;iostream&gt;</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br></sp=
an><span style=3D"color: #008;" class=3D"styled-by-prettify">struct</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> A</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;=
" class=3D"styled-by-prettify">void</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> doit</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">(){</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"> std</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">::</span><span style=3D"color: #000;" class=3D"styled-by-prettify">c=
out </span><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&l=
t;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span>=
<span style=3D"color: #080;" class=3D"styled-by-prettify">&quot;A::doit&quo=
t;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt;</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> std</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">::</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify">endl</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">}</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
};</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></sp=
an><span style=3D"color: #008;" class=3D"styled-by-prettify">struct</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> B</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;=
" class=3D"styled-by-prettify">void</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> doit</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">(){</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"> std</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">::</span><span style=3D"color: #000;" class=3D"styled-by-prettify">c=
out </span><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&l=
t;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span>=
<span style=3D"color: #080;" class=3D"styled-by-prettify">&quot;B::doit&quo=
t;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt;</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> std</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">::</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify">endl</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">}</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
};</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br>=
</span><span style=3D"color: #008;" class=3D"styled-by-prettify">int</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> main</span><span=
 style=3D"color: #660;" class=3D"styled-by-prettify">()</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">{</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><span style=3D"col=
or: #008;" class=3D"styled-by-prettify">auto</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> runtime_condition </span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" cl=
ass=3D"styled-by-prettify">true</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"><br><br>=C2=A0 =C2=A0 </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">if</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify">runtime_condition</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">)</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color: #008;" cl=
ass=3D"styled-by-prettify">goto</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"> ternary_branch_1</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"><br>=C2=A0 =C2=A0 </span><span style=3D"color: #008;" cl=
ass=3D"styled-by-prettify">else</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"=
color: #008;" class=3D"styled-by-prettify">goto</span><span style=3D"color:=
 #000;" class=3D"styled-by-prettify"> ternary_branch_2</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"><br><br>ternary_branch_1</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">:</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 A __instance1__</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 __i=
nstance1__</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
..</span><span style=3D"color: #000;" class=3D"styled-by-prettify">doit</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">();</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </sp=
an><span style=3D"color: #008;" class=3D"styled-by-prettify">return</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span styl=
e=3D"color: #066;" class=3D"styled-by-prettify">0</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;"=
 class=3D"styled-by-prettify"><br>ternary_branch_2</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">:</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 B __instance2__</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 __instance=
2__</span><span style=3D"color: #660;" class=3D"styled-by-prettify">.</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify">doit</span><span=
 style=3D"color: #660;" class=3D"styled-by-prettify">();</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><sp=
an style=3D"color: #008;" class=3D"styled-by-prettify">return</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"c=
olor: #066;" class=3D"styled-by-prettify">0</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br></span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">}</span></div></code></div><br><br><br><br><br><br><br>Am=
 Samstag, 20. Mai 2017 21:29:56 UTC+2 schrieb Thiago Macieira:<blockquote c=
lass=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px=
 #ccc solid;padding-left: 1ex;">On s=C3=A1bado, 20 de maio de 2017 10:41:56=
 PDT <a href=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"da4=
CDbczAwAJ" rel=3D"nofollow" onmousedown=3D"this.href=3D&#39;javascript:&#39=
;;return true;" onclick=3D"this.href=3D&#39;javascript:&#39;;return true;">=
ma.ka...@web.de</a> wrote:
<br>&gt; Hi Guys,
<br>&gt;=20
<br>&gt; I had the following situation:
<br>&gt;=20
<br>&gt; I have a Group of StaticSet classes with a compatible interface bu=
t
<br>&gt; distinct in there concrete type. empty_set is not an intervall!
<br>&gt; I tried the following:
<br>&gt;=20
<br>&gt;=20
<br>&gt; auto dec_digit =3D make_interval(&#39;0&#39;, &#39;0&#39; + std::m=
in(base, DECIMAL_BASE) - 1);
<br>&gt; auto upper_digit =3D (base &gt; DECIMAL_DIGIT) ? make_interval(&#3=
9;A&#39;, &#39;A&#39; + (base
<br>&gt; - 1 - DECIMAL_BASE)) : empty_set;
<br>&gt; auto lower_digit =3D (base &gt; DECIMAL_DIGIT) ? make_interval(&#3=
9;a&#39;, &#39;a&#39; + (base
<br>&gt; - 1 - DECIMAL_BASE)) : empty_set;
<br>&gt;=20
<br>&gt;=20
<br>&gt; Wouldn&#39;t it be possible to allow such code, especially in conj=
unction with
<br>&gt; concepts?
<br>
<br>No. lower_digit must have exactly one type, determined at compile-time.=
 What=20
<br>you&#39;re asking for would cause the type to be determined at runtime,=
 which is=20
<br>not possible in C++.
<br>
<br>Alternatives:
<br>* convert empty_set to make_interval&#39;s type
<br>* convert either to a common type (which you need to be explicit about,=
 so it=20
<br>=C2=A0 =C2=A0won&#39;t work with auto)
<br>* use std::variant&lt;interval, decltype(empty_set)&gt;
<br>
<br>--=20
<br>Thiago Macieira - thiago (AT) <a href=3D"http://macieira.info" target=
=3D"_blank" rel=3D"nofollow" onmousedown=3D"this.href=3D&#39;http://www.goo=
gle.com/url?q\x3dhttp%3A%2F%2Fmacieira.info\x26sa\x3dD\x26sntz\x3d1\x26usg\=
x3dAFQjCNEswDUBNCNanbu7euhqLn_62FW8ag&#39;;return true;" onclick=3D"this.hr=
ef=3D&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fmacieira.info\x26sa\x=
3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEswDUBNCNanbu7euhqLn_62FW8ag&#39;;return t=
rue;">macieira.info</a> - thiago (AT) <a href=3D"http://kde.org" target=3D"=
_blank" rel=3D"nofollow" onmousedown=3D"this.href=3D&#39;http://www.google.=
com/url?q\x3dhttp%3A%2F%2Fkde.org\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNH=
GRJdo5_JYG1DowztwAHAKs80XSA&#39;;return true;" onclick=3D"this.href=3D&#39;=
http://www.google.com/url?q\x3dhttp%3A%2F%2Fkde.org\x26sa\x3dD\x26sntz\x3d1=
\x26usg\x3dAFQjCNHGRJdo5_JYG1DowztwAHAKs80XSA&#39;;return true;">kde.org</a=
>
<br>=C2=A0 =C2=A0Software Architect - Intel Open Source Technology Center
<br>
<br></blockquote></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/99350a9e-0c6b-468d-9761-f2b2b052275e%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/99350a9e-0c6b-468d-9761-f2b2b052275e=
%40isocpp.org</a>.<br />

------=_Part_2044_681404285.1495357425404--

------=_Part_2043_190528582.1495357425403--

.
