220 30699 <CANh8DEnSUxxC2BojM+B8qpiOvrOo0qsA8stn_Yz3CMOUKD6b+Q@mail.gmail.com> article
Path: news.gmane.org!.POSTED!not-for-mail
From: "'Matt Calabrese' via ISO C++ Standard - Future Proposals" <std-proposals@isocpp.org>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: template template aliases?
Date: Mon, 30 Jan 2017 15:22:53 -0500
Lines: 161
Approved: news@gmane.org
Message-ID: <CANh8DEnSUxxC2BojM+B8qpiOvrOo0qsA8stn_Yz3CMOUKD6b+Q@mail.gmail.com>
References: <CAAvM5f8JOZqCzNwB3iKqD_wBACVL_j4EA95MbWR_yr1M=R7HbA@mail.gmail.com>
 <CANu6V4U0GDA5Zoi7Ri-fvBp+eM05gXYawQghu69MGTkdS3=91Q@mail.gmail.com>
 <CAAvM5f9ZZ6U-kPcrUBaZfjCH25urYwdM4OesLR61op9uEi4dJw@mail.gmail.com> <CAOfiQqmkNy3vXhTmx6YmQ5StNOjo02TTDBh=SCQ_tNfoqkrhvQ@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary=94eb2c096f3e8a45c90547559442
X-Trace: blaine.gmane.org 1485807778 5157 195.159.176.226 (30 Jan 2017 20:22:58 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Mon, 30 Jan 2017 20:22:58 +0000 (UTC)
To: "ISO C++ Standard - Future Proposals" <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBCGNLO5F34OBBH6BX3CAKGQEVOUZC3Y@isocpp.org Mon Jan 30 21:22:54 2017
Return-path: <std-proposals+bncBCGNLO5F34OBBH6BX3CAKGQEVOUZC3Y@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-pf0-f197.google.com ([209.85.192.197])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCGNLO5F34OBBH6BX3CAKGQEVOUZC3Y@isocpp.org>)
	id 1cYITU-00012W-Np
	for gclcip-std-proposals@m.gmane.org; Mon, 30 Jan 2017 21:22:53 +0100
Original-Received: by mail-pf0-f197.google.com with SMTP id f144sf466105227pfa.3
        for <gclcip-std-proposals@m.gmane.org>; Mon, 30 Jan 2017 12:22:58 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=mime-version:in-reply-to:references:from:date:message-id:subject:to
         :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=E5FC/o3bnEKpMQreOySJL2OCYyB9SwD/cKvu6ZAY9X4=;
        b=PAaAdhqXUsQJsMWn4G0AnC8a6RgefEkYuoya0dKl6qqWK/RuVJpomlwuBAWvgT0QX/
         pVVpmbdXO9WlHQiS1YHeJsyJjPeDdB1fW0NOqdzyrJI3OVBcOGnYHmboxRvqrDQWfumK
         osfbwuCi+NJYXdYQaB8Y6dm58hrheIMas/pB1QS2o16htqiYugMlEF7rbld6Fg0HSquM
         wI+Jh96FvGEBGFxD3zLnMgNRTKgCJgFJNYvpHP40Sl0IkpZDg8hlvpHfOlCgCa5BYdPe
         2MTAZtZLVcSi83IWUaC2ugdooikTsaQjIFv8F1lI8AEWWidr3CboS7z8orVzjeTZDC8x
         GjIQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:mime-version:in-reply-to:references:from:date
         :message-id:subject:to: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=E5FC/o3bnEKpMQreOySJL2OCYyB9SwD/cKvu6ZAY9X4=;
        b=k4dzUqfznMEEhYvTZ8byFR1ZZDF38+c/hPbnCsImZ6/iF5NBMjqaYzf7k1EWus55IS
         +CMlo13Zh7lRTFw7PkMJIRve+YkoOD1P5R6iS59FfJTc4P+uyJLY71Z0Xiw81WHn5pMw
         YZLUlZ5ANl9lZtDn+ycPLwioQg559o7OptXd+3lyGoJ/Mb6XRJaUCgtffOEV7U/Mpz93
         gvyHEkOEh4OYR+yXxAVZnV0U0/ONbsXWqJ+1u/SeuHnf0Cy3TuWSUKVaJ4dQb4t0AbVf
         lV+9EzlGq88Fj9tXQBGpc8+R8weVJ8LZ2uOhBWqQzY4xRtu8HAJdG1EvVStadGJZ2mFB
         9lfQ==
X-Gm-Message-State: AIkVDXLYfZ6OB715/v987M6IaECQHPmNW5vfQl8dO+JrjpRApZGv6B1FzuaWKrpCHZAO6Q==
X-Received: by 10.99.130.199 with SMTP id w190mr6840229pgd.158.1485807777205;
        Mon, 30 Jan 2017 12:22:57 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.157.29.8 with SMTP id m8ls7875401otm.43.gmail; Mon, 30 Jan
 2017 12:22:55 -0800 (PST)
X-Received: by 10.202.172.195 with SMTP id v186mr11567259oie.8.1485807773826;
        Mon, 30 Jan 2017 12:22:53 -0800 (PST)
Original-Received: from mail-oi0-x22f.google.com (mail-oi0-x22f.google.com. [2607:f8b0:4003:c06::22f])
        by mx.google.com with ESMTPS id p14si5886431otd.8.2017.01.30.12.22.53
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Mon, 30 Jan 2017 12:22:53 -0800 (PST)
Received-SPF: pass (google.com: domain of calabrese@google.com designates 2607:f8b0:4003:c06::22f as permitted sender) client-ip=2607:f8b0:4003:c06::22f;
Original-Received: by mail-oi0-x22f.google.com with SMTP id w204so202344301oiw.0
        for <std-proposals@isocpp.org>; Mon, 30 Jan 2017 12:22:53 -0800 (PST)
X-Received: by 10.202.240.11 with SMTP id o11mr12073417oih.198.1485807773421;
 Mon, 30 Jan 2017 12:22:53 -0800 (PST)
Original-Received: by 10.74.31.152 with HTTP; Mon, 30 Jan 2017 12:22:53 -0800 (PST)
In-Reply-To: <CAOfiQqmkNy3vXhTmx6YmQ5StNOjo02TTDBh=SCQ_tNfoqkrhvQ@mail.gmail.com>
X-Original-Sender: calabrese@google.com
X-Original-Authentication-Results: mx.google.com;       dkim=pass
 header.i=@google.com;       spf=pass (google.com: domain of
 calabrese@google.com designates 2607:f8b0:4003:c06::22f as permitted sender)
 smtp.mailfrom=calabrese@google.com;       dmarc=pass (p=REJECT sp=REJECT
 dis=NONE) header.from=google.com
X-Original-From: Matt Calabrese <calabrese@google.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:30699
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/30699>

--94eb2c096f3e8a45c90547559442
Content-Type: text/plain; charset=UTF-8

On Mon, Jan 30, 2017 at 2:47 PM, Richard Smith <richard@metafoo.co.uk>
wrote:

> Another way to get a similar effect would be to allow partial application
> of templates at the point of use instead of allowing currying in the
> definition. So (strawman syntax):
>

>   static_assert(all_of<std::is_convertible<bool, _1>, int, short, float>);
>
> where std::is_convertible<bool, _1> is a type lambda, with the above being
> shorthand for
>
>   template<typename T> using X = std::is_convertible<bool, T>;
>   static_assert(all_of<X, int, short, float>);
>
> (In fact, I think you can implement an _1 and an all_of sufficient to
> support the above as a library, but it would have a lot of limitations.)
>

That's not exactly a strawman -- Boost.MPL has had such lambdas since it
was introduced in the early 2000s. The equivalent lambda in MPL-land would
be std::is_convertible<bool, boost::mpl::_1>. In current MPL, you can apply
an MPL lambda or a "normal" metafunction class with boost::mpl::apply (in
some ways akin to a std::invoke of the metafunction world). I don't believe
MPL has an all_of algorithm, but it does have other algorithms. FWIW,
despite the magic involved, I've always found MPL's lambda facilities
better than the runtime Boost.Lambda facilties (partly because the problem
is in some ways simpler -- no value/reference binding specification, etc.).

Anyway, as someone who's done a decent amount of C++98/03 metaprogramming,
it's unfortunately no replacement for a language feature. If the complexity
of the tricks involved wasn't already enough, it's impossible to make it
work consistently with arbitrary template parameter kinds (MPL lambdas live
in a world of templates whose only template parameter kinds are types).
During composition, you can also run into the subtleties that require an
equivalent of boost::protect (mpl has a corresponding boost::mpl::protect).

I'd rather we not continue down the library route for this stuff.

On Mon, Jan 30, 2017 at 2:47 PM, Richard Smith <richard@metafoo.co.uk>
 wrote:

> Or we could support type lambdas directly (again, strawman syntax):
>
>   static_assert(all_of<[]<typename T> -> std::is_convertible<bool, T>,
> int, short, float>);
>

This seems much more reasonable to me, though I suspect that, due to its
dealing with metaprogramming, it would see push-back from some people.

On Mon, Jan 30, 2017 at 2:47 PM, Richard Smith <richard@metafoo.co.uk>
 wrote:

> ... since the above alternatives don't provide a way to specify where the
> end of the first pack is. We could perhaps get that effect with another
> extension:
>
>   template<typename ...A, typename ...B> using X = pair<tuple<A...>,
> tuple<B...>>;
>   X<int, char; float> pt; // pair<tuple<int, char>, tuple<float>>
>

Interesting idea.

-- 
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/CANh8DEnSUxxC2BojM%2BB8qpiOvrOo0qsA8stn_Yz3CMOUKD6b%2BQ%40mail.gmail.com.

--94eb2c096f3e8a45c90547559442
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote">On M=
on, Jan 30, 2017 at 2:47 PM, Richard Smith <span dir=3D"ltr">&lt;<a href=3D=
"mailto:richard@metafoo.co.uk" target=3D"_blank">richard@metafoo.co.uk</a>&=
gt;</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0px =
0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div=
 dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote"><div><di=
v class=3D"gmail-h5"><div><span style=3D"color:rgb(34,34,34)">Another way t=
o get a similar effect would be to allow partial application of templates a=
t the point of use instead of allowing currying in the definition. So (stra=
wman syntax):</span><br></div></div></div></div></div></div></blockquote><b=
lockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-le=
ft:1px solid rgb(204,204,204);padding-left:1ex"><div dir=3D"ltr"><div class=
=3D"gmail_extra"><div class=3D"gmail_quote"><div><br></div><div>=C2=A0 stat=
ic_assert(all_of&lt;std::is_<wbr>convertible&lt;bool, _1&gt;, int, short, f=
loat&gt;);<br></div><div><br></div><div>where std::is_convertible&lt;bool, =
_1&gt; is a type lambda, with the above being shorthand for</div><div><br><=
/div><div>=C2=A0 template&lt;typename T&gt; using X =3D std::is_convertible=
&lt;bool, T&gt;;</div><div>=C2=A0 static_assert(all_of&lt;X, int, short, fl=
oat&gt;);<br></div><div><br></div><div>(In fact, I think you can implement =
an _1 and an all_of sufficient to support the above as a library, but it wo=
uld have a lot of limitations.)</div></div></div></div></blockquote><div><b=
r></div><div>That&#39;s not exactly a strawman -- Boost.MPL has had such la=
mbdas since it was introduced in the early 2000s. The equivalent lambda in =
MPL-land would be std::is_convertible&lt;bool, boost::mpl::_1&gt;. In curre=
nt MPL, you can apply an MPL lambda or a &quot;normal&quot; metafunction cl=
ass with boost::mpl::apply (in some ways akin to a std::invoke of the metaf=
unction world). I don&#39;t believe MPL has an all_of algorithm, but it doe=
s have other algorithms. FWIW, despite the magic involved, I&#39;ve always =
found MPL&#39;s lambda facilities better than the runtime Boost.Lambda faci=
lties (partly because the problem is in some ways simpler -- no value/refer=
ence binding specification, etc.).</div><div><br></div><div>Anyway, as some=
one who&#39;s done a decent amount of C++98/03 metaprogramming, it&#39;s un=
fortunately no replacement for a language feature. If the complexity of the=
 tricks involved wasn&#39;t already enough, it&#39;s impossible to make it =
work consistently with arbitrary template parameter kinds (MPL lambdas live=
 in a world of templates whose only template parameter kinds are types). Du=
ring composition, you can also run into the subtleties that require an equi=
valent of boost::protect (mpl has a corresponding boost::mpl::protect).<br>=
<br></div><div>I&#39;d rather we not continue down the library route for th=
is stuff.</div><div><br></div><div>On Mon, Jan 30, 2017 at 2:47 PM, Richard=
 Smith=C2=A0<span dir=3D"ltr">&lt;<a href=3D"mailto:richard@metafoo.co.uk" =
target=3D"_blank">richard@metafoo.co.uk</a>&gt;</span>=C2=A0wrote:</div><bl=
ockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-lef=
t:1px solid rgb(204,204,204);padding-left:1ex"><div dir=3D"ltr"><div class=
=3D"gmail_extra"><div class=3D"gmail_quote"><div>Or we could support type l=
ambdas directly (again, strawman syntax):</div><div><br></div><div><div>=C2=
=A0 static_assert(all_of&lt;[]&lt;<wbr>typename T&gt; -&gt; std::is_convert=
ible&lt;bool, T&gt;, int, short, float&gt;);</div></div></div></div></div><=
/blockquote><div><br></div><div>This seems much more reasonable to me, thou=
gh I suspect that, due to its dealing with metaprogramming, it would see pu=
sh-back from some people.</div><div><br></div><div>On Mon, Jan 30, 2017 at =
2:47 PM, Richard Smith=C2=A0<span dir=3D"ltr">&lt;<a href=3D"mailto:richard=
@metafoo.co.uk" target=3D"_blank">richard@metafoo.co.uk</a>&gt;</span>=C2=
=A0wrote:=C2=A0</div><blockquote class=3D"gmail_quote" style=3D"margin:0px =
0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div=
 dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote"><div><di=
v></div><div>... since the above alternatives don&#39;t provide a way to sp=
ecify where the end of the first pack is. We could perhaps get that effect =
with another extension:</div></div><div><br></div><div>=C2=A0 template&lt;t=
ypename ...A, typename ...B&gt; using X =3D pair&lt;tuple&lt;A...&gt;, tupl=
e&lt;B...&gt;&gt;;</div><div>=C2=A0 X&lt;int, char; float&gt; pt; // pair&l=
t;tuple&lt;int, char&gt;, tuple&lt;float&gt;&gt;</div></div></div></div></b=
lockquote><div><br></div><div>Interesting idea.</div></div></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/CANh8DEnSUxxC2BojM%2BB8qpiOvrOo0qsA8s=
tn_Yz3CMOUKD6b%2BQ%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter"=
>https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CANh8DEnSUxxC=
2BojM%2BB8qpiOvrOo0qsA8stn_Yz3CMOUKD6b%2BQ%40mail.gmail.com</a>.<br />

--94eb2c096f3e8a45c90547559442--

.
