220 30696 <CAAvM5f9ZZ6U-kPcrUBaZfjCH25urYwdM4OesLR61op9uEi4dJw@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 10:10:14 -0800
Lines: 188
Approved: news@gmane.org
Message-ID: <CAAvM5f9ZZ6U-kPcrUBaZfjCH25urYwdM4OesLR61op9uEi4dJw@mail.gmail.com>
References: <CAAvM5f8JOZqCzNwB3iKqD_wBACVL_j4EA95MbWR_yr1M=R7HbA@mail.gmail.com>
 <CANu6V4U0GDA5Zoi7Ri-fvBp+eM05gXYawQghu69MGTkdS3=91Q@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary=001a11439676349fe5054753ba9d
X-Trace: blaine.gmane.org 1485799817 13000 195.159.176.226 (30 Jan 2017 18:10:17 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Mon, 30 Jan 2017 18:10:17 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCF3H2GUZUFRBCEDX3CAKGQEFSHNWJI@isocpp.org Mon Jan 30 19:10:13 2017
Return-path: <std-proposals+bncBCF3H2GUZUFRBCEDX3CAKGQEFSHNWJI@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-yb0-f200.google.com ([209.85.213.200])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCF3H2GUZUFRBCEDX3CAKGQEFSHNWJI@isocpp.org>)
	id 1cYGP5-0003BL-Hu
	for gclcip-std-proposals@m.gmane.org; Mon, 30 Jan 2017 19:10:11 +0100
Original-Received: by mail-yb0-f200.google.com with SMTP id n21sf469683657yba.7
        for <gclcip-std-proposals@m.gmane.org>; Mon, 30 Jan 2017 10:10:17 -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=/p4441YxUwrZAYLmrqry/HaALBx9cFmuhk3XOjsByPw=;
        b=nuW1rEEsa+6PHBXOvYs6qpXNMpl6K4jCPc7t7Tmbo5b8lQcI3LCiukDVzfoczN/huD
         HtIaK7vKm0dw9Jes8GfIiWOy3Kuiq7uwu5a7hYXMVNXCskGGXxrMJwSWJn2v5k5Y7XJM
         Ik+90n4IoZJ57NB44fAWUTVu9/33CRvIDSfKe7iYtqO9afI7JEO1isL/2aESpmbFC6D+
         mJ2vnnpjY+ID2qosLDu2hOIX/Sj0O49KspWa0kbp+V2qFGqYSbvy9GXMyyCQlVO2UFWS
         iCzOeeQDS4nsGNQS+R5dTKTsCZvUjpK2V2R9L8iL9MsYJVU6Jl3sf+92rG90Bs6fhhXx
         RcIQ==
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=/p4441YxUwrZAYLmrqry/HaALBx9cFmuhk3XOjsByPw=;
        b=fy0Z7PhRJ5ffogHpNJZ0jFR36IBr6qmHMmH+6BMoSFrR7jTttv0KWOGtLWTaRVB8Wg
         cYGLce59akAdR8rfGSCLTBm7bnqXiIws1Xiwwdjrl5pHCeL0Bk/KV5QeUQUfGrPqqrY6
         nqYgAa1f+kQWpZLtdxDU/5E99RCVGi4uIS565t4DSyXxRZl/VgLmqyM1LiAgiwXLAnce
         7Dvuyiqr/F2AYCV/uxPNCsyQ/d/RFdQTVPs1ep/UZZdGeu36bYFWKYRB9lqq0OaZ1EUu
         j9Ny8RijZA9w9MDuFDEIxCZPHkCIWx4MdvTMYTZuExHpIow9segFhKAnikBkvnHOIEhI
         cUMQ==
X-Gm-Message-State: AIkVDXKKac012syYjJUz6UNlIP6sDLq0v3xHi2YPLtRgJAxMLmZesntgsbsjsiRc3o7T2Q==
X-Received: by 10.13.210.69 with SMTP id u66mr6924034ywd.127.1485799816694;
        Mon, 30 Jan 2017 10:10:16 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.157.18.240 with SMTP id g103ls7428303otg.39.gmail; Mon, 30 Jan
 2017 10:10:15 -0800 (PST)
X-Received: by 10.31.98.196 with SMTP id w187mr9174525vkb.169.1485799815890;
        Mon, 30 Jan 2017 10:10:15 -0800 (PST)
Original-Received: from mail-vk0-x22c.google.com (mail-vk0-x22c.google.com. [2607:f8b0:400c:c05::22c])
        by mx.google.com with ESMTPS id b5si4014339uab.88.2017.01.30.10.10.15
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Mon, 30 Jan 2017 10:10:15 -0800 (PST)
Received-SPF: pass (google.com: domain of eric.niebler@gmail.com designates 2607:f8b0:400c:c05::22c as permitted sender) client-ip=2607:f8b0:400c:c05::22c;
Original-Received: by mail-vk0-x22c.google.com with SMTP id t8so221096516vke.3
        for <std-proposals@isocpp.org>; Mon, 30 Jan 2017 10:10:15 -0800 (PST)
X-Received: by 10.31.185.10 with SMTP id j10mr10935977vkf.9.1485799815418;
 Mon, 30 Jan 2017 10:10:15 -0800 (PST)
Original-Received: by 10.103.104.133 with HTTP; Mon, 30 Jan 2017 10:10:14 -0800 (PST)
In-Reply-To: <CANu6V4U0GDA5Zoi7Ri-fvBp+eM05gXYawQghu69MGTkdS3=91Q@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::22c 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:30696
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/30696>

--001a11439676349fe5054753ba9d
Content-Type: text/plain; charset=UTF-8

On Mon, Jan 30, 2017 at 9:38 AM, 'Johannes Schaub' via ISO C++ Standard -
Future Proposals <std-proposals@isocpp.org> wrote:

> 2017-01-30 18:24 GMT+01:00 Eric Niebler <eric.niebler@gmail.com>:
> > 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?
> >
>
> Some note about the syntax. I think you need to extend it so that
> "template" can be put after the angle brackets aswell?
>
>     template<typename T>
>     struct A { template<typename A> template<typename B> using X =
> void (A::*)(B); };
>
>     template<typename T>
>     void f() {
>        typename T::template X<string> template<size_t> p = &string::resize;
>     }
>
>     int main() { f<A>(); }
>
> Note the second "template" disambiguator.
>


Yuk. Or maybe:

    template<typename T>
    void f() {
       typename T::template template X<string><size_t> p = &string::resize;
    }

Also, yuk. On the plus side, the existence of template template aliases
would obviate most of the need to nest a template (template) alias in a
struct.

Eric

-- 
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/CAAvM5f9ZZ6U-kPcrUBaZfjCH25urYwdM4OesLR61op9uEi4dJw%40mail.gmail.com.

--001a11439676349fe5054753ba9d
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:38 AM, &#39;Johannes Schaub&#39; via ISO C++ =
Standard - Future Proposals <span dir=3D"ltr">&lt;<a href=3D"mailto:std-pro=
posals@isocpp.org" target=3D"_blank">std-proposals@isocpp.org</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 class=3D=
"gmail-HOEnZb"><div class=3D"gmail-h5">2017-01-30 18:24 GMT+01:00 Eric Nieb=
ler &lt;<a href=3D"mailto:eric.niebler@gmail.com">eric.niebler@gmail.com</a=
>&gt;:<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>
&gt;<br>
<br>
</div></div>Some note about the syntax. I think you need to extend it so th=
at<br>
&quot;template&quot; can be put after the angle brackets aswell?<br>
<br>
=C2=A0 =C2=A0 template&lt;typename T&gt;<br>
=C2=A0 =C2=A0 struct A { template&lt;typename A&gt; template&lt;typename B&=
gt; using X =3D<br>
void (A::*)(B); };<br>
<br>
=C2=A0 =C2=A0 template&lt;typename T&gt;<br>
=C2=A0 =C2=A0 void f() {<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0typename T::template X&lt;string&gt; template&lt=
;size_t&gt; p =3D &amp;string::resize;<br>
=C2=A0 =C2=A0 }<br>
<br>
=C2=A0 =C2=A0 int main() { f&lt;A&gt;(); }<br>
<br>
Note the second &quot;template&quot; disambiguator.<br></blockquote><div><b=
r></div><div><br></div><div>Yuk. Or maybe:</div><div><br></div><div>=C2=A0 =
=C2=A0 template&lt;typename T&gt;<br>=C2=A0 =C2=A0 void f() {<br>=C2=A0 =C2=
=A0 =C2=A0 =C2=A0typename T::template template X&lt;string&gt;&lt;size_t&gt=
; p =3D &amp;string::resize;<br>=C2=A0 =C2=A0 }<br></div><div><br></div><di=
v>Also, yuk. On the plus side, the existence of template template aliases w=
ould obviate most of the need to nest a template (template) alias in a stru=
ct.<br></div><div><br></div><div>Eric</div><div><br></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/CAAvM5f9ZZ6U-kPcrUBaZfjCH25urYwdM4Oes=
LR61op9uEi4dJw%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">htt=
ps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAAvM5f9ZZ6U-kPcr=
UBaZfjCH25urYwdM4OesLR61op9uEi4dJw%40mail.gmail.com</a>.<br />

--001a11439676349fe5054753ba9d--

.
