220 30693 <CAAvM5f9sOTjz=XvtDuF3iF=HahdB-xa2q9g8EiyBsxsSiA3ocw@mail.gmail.com> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Eric Niebler <eric.niebler@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: template template aliases?
Date: Mon, 30 Jan 2017 09:31:57 -0800
Lines: 155
Approved: news@gmane.org
Message-ID: <CAAvM5f9sOTjz=XvtDuF3iF=HahdB-xa2q9g8EiyBsxsSiA3ocw@mail.gmail.com>
References: <CAAvM5f8JOZqCzNwB3iKqD_wBACVL_j4EA95MbWR_yr1M=R7HbA@mail.gmail.com>
 <CAFk2RUYsJCALYoEWnirrgrmrOGfNZR82=aW8JhKSXNos8Q8tiw@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary=001a114d9d484df8310547533169
X-Trace: blaine.gmane.org 1485797520 5652 195.159.176.226 (30 Jan 2017 17:32:00 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Mon, 30 Jan 2017 17:32:00 +0000 (UTC)
Cc: Richard Smith <richardsmith@google.com>
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCF3H2GUZUFRBD7RXXCAKGQERAAEN4Y@isocpp.org Mon Jan 30 18:31:55 2017
Return-path: <std-proposals+bncBCF3H2GUZUFRBD7RXXCAKGQERAAEN4Y@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-qt0-f198.google.com ([209.85.216.198])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCF3H2GUZUFRBD7RXXCAKGQERAAEN4Y@isocpp.org>)
	id 1cYFo2-0001Jo-D8
	for gclcip-std-proposals@m.gmane.org; Mon, 30 Jan 2017 18:31:54 +0100
Original-Received: by mail-qt0-f198.google.com with SMTP id k15sf347760629qtg.5
        for <gclcip-std-proposals@m.gmane.org>; Mon, 30 Jan 2017 09:32:00 -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
         :cc: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=+3v3ybEnTOW4LrCTiG3LOPOfYrhXq34wNu/iXzUpXLc=;
        b=jubIE1xGKauztEncjGtUz8pXMnQ93XWuE+VTiVB3vSieEbqpA04tCyLePpHd2yHnoX
         KCyNfwJqMQGnOU60r9SPw3RNkrA/Sf2ZKT+JFpzm93OunVz8ng5XT7OPysQ/SJTcd9wy
         1OVdkKgB47Q8dUMCL3jAmbT8zo+mA0pkWfMJgnBhQ2AxjPfv09mnHZPv/mLekPXGpmC0
         /51aa94cQwhaxJTsGwLe4vZux64v4LLQY5obEkMHgyzU2guds9DgFZqNDGzMPz7QgrSy
         6lHA6Fqs7XkFkF6oJLDZ8tmcghFzXjYP4mMA3tkpNlByO9HlkW/zg3YDaD2jl8rRtABb
         DHUw==
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:cc: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=+3v3ybEnTOW4LrCTiG3LOPOfYrhXq34wNu/iXzUpXLc=;
        b=FnmVe5/rNa62jv23MaRoeyz94kZXvY6jbH8hRQCDUlkBxBV+UXq37vPVOU7KVjzhv/
         YZmT4SMDj7bX4dBT0B34nHHazCV1u68oBUifYb6CqU3qvsrrP+uY7dyduz6VxnaL0rfq
         br86nQm5IbLmN3wLWhRmTKnYh2W3x03sRdVjEDQcO7FnZIoVJfDT/E0kVOck+kgLWfv0
         T8pQ8E8zNZzYIkkWEvfLAbseIuWHE9ltVNXH2T6S2PHrpC6d3hXbG+S4xkTnpEh+hkRn
         L9gPF4EgoVMj2WM6wmJeeX2a4vsLl3NK6V06kR5RUAd+Wc3msh+7tNYt6udG8tE34JH6
         ALMg==
X-Gm-Message-State: AIkVDXJ2MOnpazJzrBAX/gqHlq7H3c8EGMgJWXU52QbxnbMKhZwb38BXqgB9NBf4d4D25g==
X-Received: by 10.13.240.193 with SMTP id z184mr7182072ywe.129.1485797519558;
        Mon, 30 Jan 2017 09:31:59 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.157.5.41 with SMTP id 38ls7344985otw.35.gmail; Mon, 30 Jan
 2017 09:31:58 -0800 (PST)
X-Received: by 10.31.153.8 with SMTP id b8mr10795356vke.140.1485797518880;
        Mon, 30 Jan 2017 09:31:58 -0800 (PST)
Original-Received: from mail-vk0-x241.google.com (mail-vk0-x241.google.com. [2607:f8b0:400c:c05::241])
        by mx.google.com with ESMTPS id v193si1867384vkd.117.2017.01.30.09.31.58
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Mon, 30 Jan 2017 09:31:58 -0800 (PST)
Received-SPF: pass (google.com: domain of eric.niebler@gmail.com designates 2607:f8b0:400c:c05::241 as permitted sender) client-ip=2607:f8b0:400c:c05::241;
Original-Received: by mail-vk0-x241.google.com with SMTP id r136so27055526vke.1
        for <std-proposals@isocpp.org>; Mon, 30 Jan 2017 09:31:58 -0800 (PST)
X-Received: by 10.31.200.199 with SMTP id y190mr8174324vkf.115.1485797518602;
 Mon, 30 Jan 2017 09:31:58 -0800 (PST)
Original-Received: by 10.103.104.133 with HTTP; Mon, 30 Jan 2017 09:31:57 -0800 (PST)
In-Reply-To: <CAFk2RUYsJCALYoEWnirrgrmrOGfNZR82=aW8JhKSXNos8Q8tiw@mail.gmail.com>
X-Original-Sender: eric.niebler@gmail.com
X-Original-Authentication-Results: mx.google.com;       dkim=pass
 header.i=@gmail.com;       spf=pass (google.com: domain of
 eric.niebler@gmail.com designates 2607:f8b0:400c:c05::241 as permitted
 sender) smtp.mailfrom=eric.niebler@gmail.com;       dmarc=pass (p=NONE
 sp=NONE dis=NONE) header.from=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:30693
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/30693>

--001a114d9d484df8310547533169
Content-Type: text/plain; charset=UTF-8

On Mon, Jan 30, 2017 at 9:29 AM, Ville Voutilainen <
ville.voutilainen@gmail.com> wrote:

> On 30 January 2017 at 19:24, Eric Niebler <eric.niebler@gmail.com> wrote:
> > Crazy thought.
> >
> > Why not permit template template aliases?
> >
> >   template <class A>
> >   template <class B>
> >   using Foo = pair<A, B>;
> >
> > Foo<A> is a unary template such that Foo<A><B> is pair<A,B>.
> >
> > Why?
> >
> > Higher order template metaprogramming sometimes requires passing a
> template
> > to a template. For example:
> >
> >   // with C++17 fold expressions
> >   template <template <class Ts> class Pred, class...Ts>
> >   constexpr bool all_of = (... && Pred<Ts>::value);
> >
> >   static_assert(all_of<std::is_scalar, int, short, float>);
> >
> > Q: How would you use all_of to check that all types in a pack are
> > convertible to bool?
> > A: With a "bind"-like template template alias:
> >
> >   template <template<class...> class Fn, class...As>
> >   template <class...Bs>
> >   using bind_back = Fn<Bs..., As...>;
> >
> >   template <template<class...> class Fn>
> >   template <class T>
> >   using unary = Fn<T>;
> >
> >   static_assert(all_of<unary<bind_back<std::is_convertible, bool>>, int,
> > short, float>);
> >
> > What would this language feature break?
>
>
> It mixes the water about whether an alias is a template (currently it
> isn't, it's replaced immediately and
> cannot be specialized) or not. That doesn't mean the whole idea is
> nuts, but it's probably
> something to think about.
>


Thanks for the speedy reply, Ville. You can already pass a template alias
as a template template parameter. Is this somehow different?

Eric

P.S. I owe you 2 beers in Kona.

-- 
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/CAAvM5f9sOTjz%3DXvtDuF3iF%3DHahdB-xa2q9g8EiyBsxsSiA3ocw%40mail.gmail.com.

--001a114d9d484df8310547533169
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><div class=3D"gmail_extra"><br><div class=3D"gmail_quo=
te">On Mon, Jan 30, 2017 at 9:29 AM, Ville Voutilainen <span dir=3D"ltr">&l=
t;<a href=3D"mailto:ville.voutilainen@gmail.com" target=3D"_blank">ville.vo=
utilainen@gmail.com</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quo=
te" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"=
><div class=3D"HOEnZb"><div class=3D"h5">On 30 January 2017 at 19:24, Eric =
Niebler &lt;<a href=3D"mailto:eric.niebler@gmail.com">eric.niebler@gmail.co=
m</a>&gt; wrote:<br>
&gt; Crazy thought.<br>
&gt;<br>
&gt; Why not permit template template aliases?<br>
&gt;<br>
&gt;=C2=A0 =C2=A0template &lt;class A&gt;<br>
&gt;=C2=A0 =C2=A0template &lt;class B&gt;<br>
&gt;=C2=A0 =C2=A0using Foo =3D pair&lt;A, B&gt;;<br>
&gt;<br>
&gt; Foo&lt;A&gt; is a unary template such that Foo&lt;A&gt;&lt;B&gt; is pa=
ir&lt;A,B&gt;.<br>
&gt;<br>
&gt; Why?<br>
&gt;<br>
&gt; Higher order template metaprogramming sometimes requires passing a tem=
plate<br>
&gt; to a template. For example:<br>
&gt;<br>
&gt;=C2=A0 =C2=A0// with C++17 fold expressions<br>
&gt;=C2=A0 =C2=A0template &lt;template &lt;class Ts&gt; class Pred, class..=
..Ts&gt;<br>
&gt;=C2=A0 =C2=A0constexpr bool all_of =3D (... &amp;&amp; Pred&lt;Ts&gt;::=
value);<br>
&gt;<br>
&gt;=C2=A0 =C2=A0static_assert(all_of&lt;std::is_<wbr>scalar, int, short, f=
loat&gt;);<br>
&gt;<br>
&gt; Q: How would you use all_of to check that all types in a pack are<br>
&gt; convertible to bool?<br>
&gt; A: With a &quot;bind&quot;-like template template alias:<br>
&gt;<br>
&gt;=C2=A0 =C2=A0template &lt;template&lt;class...&gt; class Fn, class...As=
&gt;<br>
&gt;=C2=A0 =C2=A0template &lt;class...Bs&gt;<br>
&gt;=C2=A0 =C2=A0using bind_back =3D Fn&lt;Bs..., As...&gt;;<br>
&gt;<br>
&gt;=C2=A0 =C2=A0template &lt;template&lt;class...&gt; class Fn&gt;<br>
&gt;=C2=A0 =C2=A0template &lt;class T&gt;<br>
&gt;=C2=A0 =C2=A0using unary =3D Fn&lt;T&gt;;<br>
&gt;<br>
&gt;=C2=A0 =C2=A0static_assert(all_of&lt;unary&lt;<wbr>bind_back&lt;std::is=
_convertible, bool&gt;&gt;, int,<br>
&gt; short, float&gt;);<br>
&gt;<br>
&gt; What would this language feature break?<br>
<br>
<br>
</div></div>It mixes the water about whether an alias is a template (curren=
tly it<br>
isn&#39;t, it&#39;s replaced immediately and<br>
cannot be specialized) or not. That doesn&#39;t mean the whole idea is<br>
nuts, but it&#39;s probably<br>
something to think about.<br></blockquote><div><br></div><div><br></div><di=
v>Thanks for the speedy reply, Ville. You can already pass a template alias=
 as a template template parameter. Is this somehow different?</div><div><br=
></div><div>Eric</div><div><br></div><div>P.S. I owe you 2 beers in Kona.</=
div><div><br></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/CAAvM5f9sOTjz%3DXvtDuF3iF%3DHahdB-xa2=
q9g8EiyBsxsSiA3ocw%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter"=
>https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAAvM5f9sOTjz=
%3DXvtDuF3iF%3DHahdB-xa2q9g8EiyBsxsSiA3ocw%40mail.gmail.com</a>.<br />

--001a114d9d484df8310547533169--

.
