220 30691 <CAAvM5f8JOZqCzNwB3iKqD_wBACVL_j4EA95MbWR_yr1M=R7HbA@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: template template aliases?
Date: Mon, 30 Jan 2017 09:24:00 -0800
Lines: 96
Approved: news@gmane.org
Message-ID: <CAAvM5f8JOZqCzNwB3iKqD_wBACVL_j4EA95MbWR_yr1M=R7HbA@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary=f403045e34b4d74bb40547531456
X-Trace: blaine.gmane.org 1485797041 6735 195.159.176.226 (30 Jan 2017 17:24:01 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Mon, 30 Jan 2017 17:24:01 +0000 (UTC)
Cc: Richard Smith <richardsmith@google.com>
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCF3H2GUZUFRBMPNXXCAKGQEKBNN7YQ@isocpp.org Mon Jan 30 18:23:57 2017
Return-path: <std-proposals+bncBCF3H2GUZUFRBMPNXXCAKGQEKBNN7YQ@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-vk0-f71.google.com ([209.85.213.71])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCF3H2GUZUFRBMPNXXCAKGQEKBNN7YQ@isocpp.org>)
	id 1cYFgL-0001bF-1D
	for gclcip-std-proposals@m.gmane.org; Mon, 30 Jan 2017 18:23:57 +0100
Original-Received: by mail-vk0-f71.google.com with SMTP id x75sf192608715vke.5
        for <gclcip-std-proposals@m.gmane.org>; Mon, 30 Jan 2017 09:24:02 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=mime-version: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=V2TtfXtzYoW3EQmr24mPP0Ams/Jz4lh3el5p9FrfELc=;
        b=zmQhsUSlYZLhYWsNhSRBWPBvpAgZZn/tjDYSH3AyudGsHYAY+p9iR8aFlmSlwGC1WI
         zEuA2ArHmTQOrUZzzGA+xfAEWYqiGU+fTwlxtP+VAvdSB3Y/1wBciMZji5+9ZvSJxT50
         W9xauNqPZH+2KX14pLFcmIth6jdHqReEY4wZP9tNJiSAnEI7JthZmTSEiumnNtHVUi6w
         7uuFf7zarqsgUZXw+vRCxDo8eGVrG/YnvPAzd1HedWo4QCgFC9hmcG6JOjg0ixxgEBbW
         zU3jFswAgS8RvG3hf5X1LT232LLAV7hdTxU/I4JUcaoamgT1hJKugZd2rwfexNIjd16p
         7Jgw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:mime-version: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=V2TtfXtzYoW3EQmr24mPP0Ams/Jz4lh3el5p9FrfELc=;
        b=j/xQBEDQRAvPxjUjBbzfsJnVbogmBddG1g0/0AjieCBDyL857R6jcvUQ172tdlZ6+p
         R/hD8f4BU6JjvUt1Z73cP8Jnl1WUXuKs1G/WLtp5u7yWrV7zaKniDz1aGbcTNGHCZ48T
         PzWXyMib2NiYc/yxmoKR2F9HOAp8X4colwgvff1JUhKNybQeDQlhIONWPaRfym9dt8sv
         +wqzA4/7PkzD5r+jwUeOOv2FrFBxUyItVmvmMxcP876AbS0ygfFWY+bEl5wD4MXqjknF
         Tf0O4l16dxxgkNuwBYcqBoX8mjiskyOguRxeEuSdr9AAp6WPvtdVxWXLsY2qtqF1OOEU
         iE8g==
X-Gm-Message-State: AIkVDXJl96TlvSRQfSUYuCAvdbUbcJhrEE1u9VNSS+FSkSRW0BwReKsfkptgWN8h1dQ2Ng==
X-Received: by 10.31.190.140 with SMTP id o134mr4919351vkf.17.1485797042266;
        Mon, 30 Jan 2017 09:24:02 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.157.10.79 with SMTP id 73ls8284451otg.29.gmail; Mon, 30 Jan
 2017 09:24:01 -0800 (PST)
X-Received: by 10.176.3.236 with SMTP id 99mr9456882uau.96.1485797041343;
        Mon, 30 Jan 2017 09:24:01 -0800 (PST)
Original-Received: from mail-ua0-x243.google.com (mail-ua0-x243.google.com. [2607:f8b0:400c:c08::243])
        by mx.google.com with ESMTPS id k25si3961096uab.178.2017.01.30.09.24.01
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Mon, 30 Jan 2017 09:24:01 -0800 (PST)
Received-SPF: pass (google.com: domain of eric.niebler@gmail.com designates 2607:f8b0:400c:c08::243 as permitted sender) client-ip=2607:f8b0:400c:c08::243;
Original-Received: by mail-ua0-x243.google.com with SMTP id i68so30839194uad.1
        for <std-proposals@isocpp.org>; Mon, 30 Jan 2017 09:24:01 -0800 (PST)
X-Received: by 10.159.48.69 with SMTP id i5mr11574678uab.121.1485797041062;
 Mon, 30 Jan 2017 09:24:01 -0800 (PST)
Original-Received: by 10.103.104.133 with HTTP; Mon, 30 Jan 2017 09:24:00 -0800 (PST)
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:c08::243 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:30691
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/30691>

--f403045e34b4d74bb40547531456
Content-Type: text/plain; charset=UTF-8

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?

Thanks,
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/CAAvM5f8JOZqCzNwB3iKqD_wBACVL_j4EA95MbWR_yr1M%3DR7HbA%40mail.gmail.com.

--f403045e34b4d74bb40547531456
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Crazy thought.<div><br></div><div>Why not permit template =
template aliases?</div><div><br></div><div>=C2=A0 template &lt;class A&gt;<=
/div><div>=C2=A0 template &lt;class B&gt;</div><div>=C2=A0 using Foo =3D pa=
ir&lt;A, B&gt;;</div><div><br></div><div>Foo&lt;A&gt; is a unary template s=
uch that Foo&lt;A&gt;&lt;B&gt; is pair&lt;A,B&gt;.</div><div><br></div><div=
>Why?</div><div><br></div><div>Higher order template metaprogramming someti=
mes requires passing a template to a template. For example:<div><br></div><=
div>=C2=A0 // with C++17 fold expressions</div><div>=C2=A0 template &lt;tem=
plate &lt;class Ts&gt; class Pred, class...Ts&gt;</div><div>=C2=A0 constexp=
r bool all_of =3D (... &amp;&amp; Pred&lt;Ts&gt;::value);</div><div><br></d=
iv><div>=C2=A0 static_assert(all_of&lt;std::is_scalar, int, short, float&gt=
;);</div><div><br></div><div>Q: How would you use all_of to check that all =
types in a pack are convertible to bool?</div><div>A: With a &quot;bind&quo=
t;-like template template alias:</div><div><br></div><div>=C2=A0 template &=
lt;template&lt;class...&gt; class Fn, class...As&gt;</div><div>=C2=A0 templ=
ate &lt;class...Bs&gt;</div><div>=C2=A0 using bind_back =3D Fn&lt;Bs..., As=
....&gt;;</div><div><br></div><div>=C2=A0 template &lt;template&lt;class...&=
gt; class Fn&gt;</div><div>=C2=A0 template &lt;class T&gt;</div><div>=C2=A0=
 using unary =3D Fn&lt;T&gt;;</div><div><br></div><div>=C2=A0 static_assert=
(all_of&lt;unary&lt;bind_back&lt;std::is_convertible, bool&gt;&gt;, int, sh=
ort, float&gt;);</div><div><br></div><div>What would this language feature =
break?</div></div><div><br></div><div>Thanks,</div><div>Eric</div><div><br>=
</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/CAAvM5f8JOZqCzNwB3iKqD_wBACVL_j4EA95M=
bWR_yr1M%3DR7HbA%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">h=
ttps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAAvM5f8JOZqCzN=
wB3iKqD_wBACVL_j4EA95MbWR_yr1M%3DR7HbA%40mail.gmail.com</a>.<br />

--f403045e34b4d74bb40547531456--

.
