220 30777 <3fbbd6b8-9087-4c02-bf66-632b7eff480d@isocpp.org> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Bengt Gustafsson <bengt.gustafsson@beamways.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Make Typedef Great Again
Date: Sun, 5 Feb 2017 05:22:36 -0800 (PST)
Lines: 269
Approved: news@gmane.org
Message-ID: <3fbbd6b8-9087-4c02-bf66-632b7eff480d@isocpp.org>
References: <cfbe556f-214a-4245-b257-f746424c63f2@isocpp.org>
 <b1ae66d2-da65-bd04-6ac0-8bed1d13c5c5@wanadoo.fr>
 <fc42405f-b5de-492a-9e7e-e191a6dd975c@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_1026_1088320546.1486300956941"
X-Trace: blaine.gmane.org 1486300959 6047 195.159.176.226 (5 Feb 2017 13:22:39 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Sun, 5 Feb 2017 13:22:39 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBCRIRSPDTQIRBHOO3TCAKGQENXGBJKA@isocpp.org Sun Feb 05 14:22:34 2017
Return-path: <std-proposals+bncBCRIRSPDTQIRBHOO3TCAKGQENXGBJKA@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-pf0-f199.google.com ([209.85.192.199])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCRIRSPDTQIRBHOO3TCAKGQENXGBJKA@isocpp.org>)
	id 1caMm1-0001Hg-8V
	for gclcip-std-proposals@m.gmane.org; Sun, 05 Feb 2017 14:22:33 +0100
Original-Received: by mail-pf0-f199.google.com with SMTP id y143sf78935017pfb.6
        for <gclcip-std-proposals@m.gmane.org>; Sun, 05 Feb 2017 05:22:39 -0800 (PST)
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=pzKzSepzXcNVLWd31irdsHvIsxU5Sx8IIA8fAif5swA=;
        b=HCRFb00PHroYp9jG9eBaan61DUpiUtFP8kRv3zMeMlgMBVc/yCFjzrhFMtJCSl3c2V
         Q12Utp1gJSTRuVMkKcyZaOGwxKsEDAOGj9XRPGGdm0aPrZ9nmUZLqbpluvXVlTmj+cHA
         /GjOVvpKpVB2k87HbFFz819qph4n3d78K2t5KZAdn8cZMfaenZ5+uiCqcH8CwcfhheUV
         ZXSV3+0eZWWtZOZqcAb51B5zaMei8u8sx3X4oY+JtTucz7ss6M2LWeERHNsgzDw3P7Ym
         Of+OPs1F7O09DXUb4X58JHBalvVnCkQwFo2s20earVZvkatk29I8nLwmfkCi7JAh35Df
         qOKQ==
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=pzKzSepzXcNVLWd31irdsHvIsxU5Sx8IIA8fAif5swA=;
        b=qiAtRhjp87SlB1Z7+NusatAGVIThFnARhhA5dOFtMsJOFxfY2RCd32mdU1BuPIytq8
         BOq+FgdssxC7+ejIPZcI/WvMWElGspbk+bRtCjzXAhUofB9YP3Nnz2KhSMdn83Z9S8MC
         Zu0S/jnC08PcisJNz+2s+MCgPolE38HdxJEB/ei665ZnzrUJN5mWCa5ucmeFtsKX8U7x
         P86qYFUhi2LktKcE7n8MEMbQeOYdsuLYoErfYO2/OprKYK/6Ot0XA/hPXGro/pfeA+ei
         gsRHucg4xmnZxAENRW3AeuP6aSkqogPcn9Vi+XgsyjUyLSa8Tzp2HjK3cjJ3nHIrGZlc
         sKXw==
X-Gm-Message-State: AIkVDXL2cU8mtyBqRnjUzCmY6eDFCgj5HHUMrw4AvxA2DucsXLoRF1950+SC6EIHLvH60Q==
X-Received: by 10.99.132.195 with SMTP id k186mr1474153pgd.147.1486300958488;
        Sun, 05 Feb 2017 05:22:38 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.157.0.1 with SMTP id 1ls11525196ota.5.gmail; Sun, 05 Feb 2017
 05:22:37 -0800 (PST)
X-Received: by 10.157.18.211 with SMTP id g77mr320670otg.14.1486300957457;
        Sun, 05 Feb 2017 05:22:37 -0800 (PST)
In-Reply-To: <fc42405f-b5de-492a-9e7e-e191a6dd975c@isocpp.org>
X-Original-Sender: bengt.gustafsson@beamways.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:30777
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/30777>

------=_Part_1026_1088320546.1486300956941
Content-Type: multipart/alternative; 
	boundary="----=_Part_1027_635710659.1486300956942"

------=_Part_1027_635710659.1486300956942
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

@Vicente: You present some nice solutions for the current language, but the=
=20
drawback is of course that it is not obvious that it is *forbidden* to=20
change the default value of the parameter. The other, minor, issue is that=
=20
the template parameter name is not usable outside the template itself,=20
which the typedef name would be.

Nevertheless it is of course advisable to mention theses possibilities in a=
=20
future proposal, as you say.

I see a problem with the proposal in that it has fairly complicated rules=
=20
to learn, and the meaning differs depending on where you place your=20
public's and const's. I'm not sure if the utility of the function outweighs=
=20
the extra burden of having to learn and remember these extra rules.

We also have decltype to solve some of the use cases.


Den s=C3=B6ndag 5 februari 2017 kl. 13:56:12 UTC+1 skrev TONGARI J:
>
> On Sunday, February 5, 2017 at 6:41:36 PM UTC+8, Vicente J. Botet Escriba=
=20
> wrote:=20
>>
>> I'm not saying the feature is not needed. I believe however that the=20
>> proposal needs to compare what it is currently doable.
>>
>> Couldn't we use the existing language already
>>
>> template<blahblah..., typename T =3D typename MetaFunc<blahblah...>::typ=
e >
>> T f() // yay!
>> {
>>     // Use `T` from now on...
>> }
>>
>> In this case, it's just an alternative w/o (ab)using the template param,=
=20
> like how concept-lite tries to eliminate enable_if trick.
> =20
>
>> template<blahblah..., typename Base=3Dtypename MetaFunc<blahblah...>::ty=
pe>
>> class Derived : public Base // yay!
>> {
>>     // Use `Base` from now on...
>> }
>>
> =20
> This does not work if "blahblah...", is actually a template parameter=20
> pack, which has to be the last one.
>
>> In parameter list:
>> template<blahblah...>
>> void f(typedef SomeTemplate<blahblah...> T a, T b); // yay!
>>
>> I'm not sure the blahblah could be inferred
>>
>> Do tou mean
>>
>>
>> template<class U>
>> void f(U, typedef SomeTemplate<U> T a, T b);
>>
>
> I mean something like:
> template<class... Args>
> void f(typedef std::tuple<Args...> T a, T b);
>
> f(std::make_tuple(1, 2), std::make_tuple(3, 4)); //Args =3D=3D {int, int}=
, T=20
> =3D=3D std::tuple<int, int>
>

--=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/3fbbd6b8-9087-4c02-bf66-632b7eff480d%40isocpp.or=
g.

------=_Part_1027_635710659.1486300956942
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">@Vicente: You present some nice solutions for the current =
language, but the drawback is of course that it is not obvious that it is <=
i>forbidden</i>=C2=A0to change the default value of the parameter. The othe=
r, minor, issue is that the template parameter name is not usable outside t=
he template itself, which the typedef name would be.<div><br></div><div>Nev=
ertheless it is of course advisable to mention theses possibilities in a fu=
ture proposal, as you say.</div><div><br></div><div>I see a problem with th=
e proposal in that it has fairly complicated rules to learn, and the meanin=
g differs depending on where you place your public&#39;s and const&#39;s. I=
&#39;m not sure if the utility of the function outweighs the extra burden o=
f having to learn and remember these extra rules.</div><div><br></div><div>=
We also have decltype to solve some of the use cases.</div><div><br><br>Den=
 s=C3=B6ndag 5 februari 2017 kl. 13:56:12 UTC+1 skrev TONGARI J:<blockquote=
 class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1=
px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr">On Sunday, February 5, 2=
017 at 6:41:36 PM UTC+8, Vicente J. Botet Escriba wrote:=C2=A0<blockquote c=
lass=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #c=
cc solid;padding-left:1ex"><div bgcolor=3D"#FFFFFF" text=3D"#000000"><div>I=
&#39;m not saying the feature is not needed. I believe however that the
    proposal needs to compare what it is currently doable.<br></div>
    <br>
    Couldn&#39;t we use the existing language already<br>
    <br>
    <div style=3D"background-color:rgb(250,250,250);border-color:rgb(187,18=
7,187);border-style:solid;border-width:1px;word-wrap:break-word"><code>
        <div><span style=3D"color:#008">template</span><span style=3D"color=
:#660">&lt;</span><span style=3D"color:#000">blahblah</span><span style=3D"=
color:#660">...,
            typename T =3D </span><span style=3D"color:#660"><code><span st=
yle=3D"color:#000"></span><span style=3D"color:#008">typename</span><span s=
tyle=3D"color:#000"> </span><span style=3D"color:#606">MetaFunc</span><span=
 style=3D"color:#660">&lt;</span><span style=3D"color:#000">blahblah</span>=
<span style=3D"color:#660">...&gt;::</span><span style=3D"color:#000">type =
</span></code>&gt;</span><span style=3D"color:#000"><br>
          </span><span style=3D"color:#000">T
            f</span><span style=3D"color:#660">()</span><span style=3D"colo=
r:#000"> </span><span style=3D"color:#800">// yay!</span><span style=3D"col=
or:#000"><br>
          </span><span style=3D"color:#660">{</span><span style=3D"color:#0=
00"><br>
            =C2=A0 =C2=A0 </span><span style=3D"color:#800">// Use `T` from=
 now on...</span><span style=3D"color:#000"><br>
          </span><span style=3D"color:#660">}</span></div>
      </code></div>
    <blockquote type=3D"cite">
      <div dir=3D"ltr">
        <div></div></div></blockquote></div></blockquote><div>In this case,=
 it&#39;s just an alternative w/o (ab)using the template param, like how co=
ncept-lite tries to eliminate enable_if trick.</div><div>=C2=A0</div><block=
quote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left=
:1px #ccc solid;padding-left:1ex"><div bgcolor=3D"#FFFFFF" text=3D"#000000"=
>
    <div style=3D"background-color:rgb(250,250,250);border-color:rgb(187,18=
7,187);border-style:solid;border-width:1px;word-wrap:break-word"><code>
        <div><span style=3D"color:#008">template</span><span style=3D"color=
:#660">&lt;</span><span style=3D"color:#000">blahblah</span><span style=3D"=
color:#660">...,
            typename Base=3D</span><span style=3D"color:#660"><code><span s=
tyle=3D"color:#000"></span><span style=3D"color:#008">typename</span><span =
style=3D"color:#000"> </span><span style=3D"color:#606">MetaFunc</span><spa=
n style=3D"color:#660">&lt;</span><span style=3D"color:#000">blahblah</span=
><span style=3D"color:#660">...&gt;::</span><span style=3D"color:#000">type=
</span></code>&gt;</span><span style=3D"color:#000"><br>
          </span><span style=3D"color:#008">class</span><span style=3D"colo=
r:#000"> </span><span style=3D"color:#606">Derived</span><span style=3D"col=
or:#000"> </span><span style=3D"color:#660">:</span><span style=3D"color:#0=
00"> </span><span style=3D"color:#000"></span><span style=3D"color:#008">pu=
blic</span><span style=3D"color:#000"> </span><span style=3D"color:#000"></=
span><span style=3D"color:#606">Base</span><span style=3D"color:#000"> </sp=
an><span style=3D"color:#800">// yay!</span><span style=3D"color:#000"><br>
          </span><span style=3D"color:#660">{</span><span style=3D"color:#0=
00"><br>
            =C2=A0 =C2=A0 </span><span style=3D"color:#800">// Use `Base` f=
rom now on...</span><span style=3D"color:#000"><br>
          </span><span style=3D"color:#660">}</span></div></code></div></di=
v></blockquote><div>=C2=A0</div><div>This does not work if &quot;<span styl=
e=3D"background-color:rgb(250,250,250);color:rgb(0,0,0);font-family:monospa=
ce">blahblah...</span>&quot;, is actually a template parameter pack, which =
has to be the last one.</div><blockquote class=3D"gmail_quote" style=3D"mar=
gin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex"><div b=
gcolor=3D"#FFFFFF" text=3D"#000000"><blockquote type=3D"cite">
      <div dir=3D"ltr">
       =20
        <div>In parameter list:</div>
        <div style=3D"background-color:rgb(250,250,250);border-color:rgb(18=
7,187,187);border-style:solid;border-width:1px;word-wrap:break-word"><code>
            <div><span style=3D"color:#008">template</span><span style=3D"c=
olor:#660">&lt;</span><span style=3D"color:#000">blahblah</span><span style=
=3D"color:#660">...&gt;</span><span style=3D"color:#000"><br>
              </span><span style=3D"color:#008">void</span><span style=3D"c=
olor:#000"> f</span><span style=3D"color:#660">(</span><span style=3D"color=
:#008">typedef</span><span style=3D"color:#000"> </span><span style=3D"colo=
r:#606">SomeTemplate</span><span style=3D"color:#660">&lt;</span><span styl=
e=3D"color:#000">blahblah</span><span style=3D"color:#660">...&gt;</span><s=
pan style=3D"color:#000"> T a</span><span style=3D"color:#660">,</span><spa=
n style=3D"color:#000"> T b</span><span style=3D"color:#660">);</span><span=
 style=3D"color:#000"> </span><span style=3D"color:#800">// yay!</span></di=
v>
          </code></div>
        <div><br>
        </div>
      </div>
    </blockquote>
    I&#39;m not sure the <code><span style=3D"color:#660"></span><span styl=
e=3D"color:#000">blahblah</span><span style=3D"color:#660"> could be
        inferred<br>
        <br>
        Do tou mean<br>
        <br>
      </span></code><br>
    <code><span style=3D"color:#008">template</span><span style=3D"color:#6=
60">&lt;class U</span><span style=3D"color:#660">&gt;</span><span style=3D"=
color:#000"><br>
      </span><span style=3D"color:#008">void</span><span style=3D"color:#00=
0"> f</span><span style=3D"color:#660">(U, </span><span style=3D"color:#008=
">typedef</span><span style=3D"color:#000"> </span><span style=3D"color:#60=
6">SomeTemplate</span><span style=3D"color:#660">&lt;</span><span style=3D"=
color:#000">U</span><span style=3D"color:#660">&gt;</span><span style=3D"co=
lor:#000"> T a</span><span style=3D"color:#660">,</span><span style=3D"colo=
r:#000"> T b</span><span style=3D"color:#660">);<br></span></code></div></b=
lockquote><div><br></div><div>I mean something like:</div><div style=3D"bac=
kground-color:rgb(250,250,250);border-color:rgb(187,187,187);border-style:s=
olid;border-width:1px;word-wrap:break-word"><code><div><span style=3D"color=
:#008">template</span><span style=3D"color:#660">&lt;</span><span style=3D"=
color:#008">class</span><span style=3D"color:#660">...</span><span style=3D=
"color:#000"> </span><span style=3D"color:#606">Args</span><span style=3D"c=
olor:#660">&gt;</span><span style=3D"color:#000"><br></span><span style=3D"=
color:#008">void</span><span style=3D"color:#000"> f</span><span style=3D"c=
olor:#660">(</span><span style=3D"color:#008">typedef</span><span style=3D"=
color:#000"> std</span><span style=3D"color:#660">::</span><span style=3D"c=
olor:#000">tuple</span><span style=3D"color:#660">&lt;</span><span style=3D=
"color:#606">Args</span><span style=3D"color:#660">...&gt;</span><span styl=
e=3D"color:#000"> T a</span><span style=3D"color:#660">,</span><span style=
=3D"color:#000"> T b</span><span style=3D"color:#660">);</span><span style=
=3D"color:#000"><br><br></span><font color=3D"#660066"><span style=3D"color=
:#000">f</span><span style=3D"color:#660">(</span><span style=3D"color:#000=
">std</span><span style=3D"color:#660">::</span><span style=3D"color:#000">=
make_tuple</span><span style=3D"color:#660">(</span><span style=3D"color:#0=
66">1</span><span style=3D"color:#660">,</span><span style=3D"color:#000"> =
</span><span style=3D"color:#066">2</span><span style=3D"color:#660">),</sp=
an><span style=3D"color:#000"> </span></font><span style=3D"color:#000">std=
</span><span style=3D"color:#660">::</span><span style=3D"color:#000">make_=
tuple</span><span style=3D"color:#660">(</span><font color=3D"#006666"><spa=
n style=3D"color:#066">3</span><span style=3D"color:#660">,</span><span sty=
le=3D"color:#000"> </span><span style=3D"color:#066">4</span></font><span s=
tyle=3D"color:#660">));</span><span style=3D"color:#000"> </span><span styl=
e=3D"color:#800">//Args =3D=3D {int, int}, T =3D=3D std::tuple&lt;int, int&=
gt;</span></div></code></div></div></blockquote></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/3fbbd6b8-9087-4c02-bf66-632b7eff480d%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/3fbbd6b8-9087-4c02-bf66-632b7eff480d=
%40isocpp.org</a>.<br />

------=_Part_1027_635710659.1486300956942--

------=_Part_1026_1088320546.1486300956941--

.
