220 16679 <DE41A290-9723-4C76-AB7F-00C391C9CDAE@microsoft.com> article
Path: news.gmane.org!not-for-mail
From: Gabriel Dos Reis <gdr@microsoft.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals,gmane.comp.lang.c++.isocpp.general
Subject: Re: An implementation of enhanced auto deduction and
 abbreviated template syntax using Clang
Date: Wed, 4 Mar 2015 03:45:01 +0000
Lines: 97
Approved: news@gmane.org
Message-ID: <DE41A290-9723-4C76-AB7F-00C391C9CDAE@microsoft.com>
References: <CABsSThrwV0UCbrmoxoeQUskOjvF2+RX5ctpSq3dPMPxm=t6mww@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
X-Trace: ger.gmane.org 1425440719 21433 80.91.229.3 (4 Mar 2015 03:45:19 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Wed, 4 Mar 2015 03:45:19 +0000 (UTC)
Cc: "std-discussion@isocpp.org" <std-discussion@isocpp.org>,
	"c++std-core@accu.org" <c++std-core@accu.org>
To: "<std-proposals@isocpp.org>" <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBC76L47644CRBQH73GTQKGQER3OC53Y@isocpp.org Wed Mar 04 04:45:06 2015
Return-path: <std-proposals+bncBC76L47644CRBQH73GTQKGQER3OC53Y@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-ob0-f198.google.com ([209.85.214.198])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBC76L47644CRBQH73GTQKGQER3OC53Y@isocpp.org>)
	id 1YT0F8-0002Nq-GV
	for gclcip-std-proposals@m.gmane.org; Wed, 04 Mar 2015 04:45:06 +0100
Original-Received: by obcuz6 with SMTP id uz6sf22403186obc.1
        for <gclcip-std-proposals@m.gmane.org>; Tue, 03 Mar 2015 19:45:05 -0800 (PST)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:from:to:cc:subject:thread-topic:thread-index
         :date:message-id:references:in-reply-to:accept-language
         :content-language:content-type:mime-version:x-original-sender
         :x-original-authentication-results:reply-to:precedence:mailing-list
         :list-id:list-post:list-help:list-archive:list-subscribe
         :list-unsubscribe;
        bh=KjwdTCp7Q2BFLK1lvcr8mA/FZDVqrh6ZDTAmOKmhmgk=;
        b=EUclp2wIGus0KB8AcheSpvQfLO8mAr7Wl2mlsktdtocaGMMnwaaHxVPGW3HbE7nWan
         5dA3VgET9KpVCYJlWrDzIORSsnLHTBTPUzO1cFp2yba4+AA89XIzkybaqDgn2vzu1Nxf
         ZXEDRNAk7VESKOMu6sMeycYeB5zin4izbzEqE0OX7zLUP4018IJ+hqM848Z1HbKcco2z
         lrD0elDBjw5+2b+NSjadj7YgaMqnZGC9UjyWkKkdYvdrI7Fv/8xzW0CbPIozD9300aJy
         Yv3PXRzHbMWV3fKwfSsPq0NPUjf+c9jzQuyRrV9K2OZP6t 
X-Gm-Message-State: ALoCoQled58TjY6RyH1XEsovLde4F7BQ4UIhvpXYahvICLqvaxxuQrcCtfQsRjOGnBYpQarekPEu
X-Received: by 10.183.10.164 with SMTP id eb4mr2531204obd.48.1425440705366;
        Tue, 03 Mar 2015 19:45:05 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.107.163.208 with SMTP id m199ls448756ioe.59.gmail; Tue, 03 Mar
 2015 19:45:04 -0800 (PST)
X-Received: by 10.68.136.167 with SMTP id qb7mr2990180pbb.155.1425440704513;
        Tue, 03 Mar 2015 19:45:04 -0800 (PST)
Original-Received: from na01-bn1-obe.outbound.protection.outlook.com (mail-bn1on0145.outbound.protection.outlook.com. [157.56.110.145])
        by mx.google.com with ESMTPS id bq3si2927536pdb.238.2015.03.03.19.45.04
        (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128);
        Tue, 03 Mar 2015 19:45:04 -0800 (PST)
Received-SPF: pass (google.com: domain of gdr@microsoft.com designates 157.56.110.145 as permitted sender) client-ip=157.56.110.145;
Original-Received: from DM2PR0301MB0912.namprd03.prod.outlook.com (25.160.217.142) by
 DM2PR0301MB0686.namprd03.prod.outlook.com (25.160.96.24) with Microsoft SMTP
 Server (TLS) id 15.1.93.16; Wed, 4 Mar 2015 03:45:03 +0000
Original-Received: from DM2PR0301MB0911.namprd03.prod.outlook.com (25.160.217.141) by
 DM2PR0301MB0912.namprd03.prod.outlook.com (25.160.217.142) with Microsoft
 SMTP Server (TLS) id 15.1.99.14; Wed, 4 Mar 2015 03:45:01 +0000
Original-Received: from DM2PR0301MB0911.namprd03.prod.outlook.com ([25.160.217.141]) by
 DM2PR0301MB0911.namprd03.prod.outlook.com ([25.160.217.141]) with mapi id
 15.01.0099.004; Wed, 4 Mar 2015 03:45:01 +0000
Thread-Topic: [std-proposals] An implementation of enhanced auto deduction and
 abbreviated template syntax using Clang
Thread-Index: AQHQViR9WPFdJKanw0SwhTnX43nE7p0LruZv
In-Reply-To: <CABsSThrwV0UCbrmoxoeQUskOjvF2+RX5ctpSq3dPMPxm=t6mww@mail.gmail.com>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach: 
X-MS-TNEF-Correlator: 
x-originating-ip: [73.35.173.108]
x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DM2PR0301MB0912;UriScan:;
x-microsoft-antispam-prvs: <DM2PR0301MB091201F37FA1D73364B08D09F31E0@DM2PR0301MB0912.namprd03.prod.outlook.com>
x-exchange-antispam-report-test: UriScan:;
x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(601004)(5005006);SRVR:DM2PR0301MB0912;BCL:0;PCL:0;RULEID:;SRVR:DM2PR0301MB0912;
x-forefront-prvs: 0505147DDB
x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(979002)(6009001)(199003)(24454002)(51704005)(189002)(377454003)(41574002)(106116001)(50986999)(36756003)(76176999)(92566002)(54356999)(33656002)(99286002)(19580395003)(82746002)(19580405001)(62966003)(77156002)(86612001)(2950100001)(102836002)(66066001)(40100003)(122556002)(46102003)(83716003)(87936001)(2900100001)(86362001)(15975445007)(2656002)(110136001)(104396002)(491001)(969003)(989001)(999001)(1009001)(1019001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM2PR0301MB0912;H:DM2PR0301MB0911.namprd03.prod.outlook.com;FPR:;SPF:None;MLV:ovrnspm;PTR:InfoNoRecords;A:1;MX:1;LANG:en;
received-spf: None (protection.outlook.com: microsoft.com does not designate
 permitted sender hosts)
X-MS-Exchange-CrossTenant-originalarrivaltime: 04 Mar 2015 03:45:01.3922
 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47
X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR0301MB0912
X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:;SRVR:DM2PR0301MB0686;
X-OriginatorOrg: microsoft.onmicrosoft.com
X-Original-Sender: gdr@microsoft.com
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of gdr@microsoft.com designates 157.56.110.145 as permitted sender)
 smtp.mail=gdr@microsoft.com;       dmarc=pass (p=NONE dis=NONE) header.from=microsoft.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: <http://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <http://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <http://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <http://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>,
 <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:16679 gmane.comp.lang.c++.isocpp.general:4951
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/16679>

Should we declare "auto f(auto) -> auto" an excess in sophism?

-- Gaby


> On Mar 3, 2015, at 6:39 PM, Faisal Vali <faisalv@gmail.com> wrote:
> 
> In the hopes of soliciting constructive feedback, if anyone has the
> time or the interest to play with a patched up Clang that implements
> enhanced auto deduction & abbreviated template syntax from the
> concepts ts, here it is:
> 
> https://github.com/faisalv/clang/tree/enhanced-auto-c%2B%2B1z .
> 
> The last line of the README file tells you the subversion revision of
> LLVM to use.
> 
> For examples of test cases that successfully compile, please refer to:
> -- https://github.com/faisalv/clang/blob/enhanced-auto-c%2B%2B1z/test/CXX/auto/cxx1z-auto-vars-generalized.cpp
> -- https://github.com/faisalv/clang/blob/enhanced-auto-c%2B%2B1z/test/CXX/auto/cxx1z-abbreviated-templates.cpp
> 
> I would certainly appreciate the feedback!
> 
> 1) Enhanced-Auto Deduction:
> 
> pair<auto...> f() { return make_pair([] { }, [] { }); }
> vector<auto> v = vector<int>();
> 
> 2) Abbreviated Template Syntax:
> void f(auto) <=> template<class T> void f(T);
> 
> 
> A few, perhaps not so obvious or interesting, technicalities:
> 
> a)  The equivalence of templates when it comes to trailing return
> types in function pointer parameters is based on the order of the
> 'auto' that signifies a placeholder, not just the appearance of an
> auto in the declaration-specifier of a parameter:
> 
>    template<class R, class P> void f( R(P) );  // #1
>    template<class P, class R> void f(  R(P) );  // #2 (order of
> templ-params flipped)
> 
>    template<class R, class P> void f( auto (P)->R); // equivalent to
> #1, not abbreviated.
>    void f(auto(auto));  // equivalent to #1
>    void f(auto (auto) -> auto); // equivalent to #2
>                                               // the trailing return type auto
>                                               // identifies a
> template parameter
>    template<class R> void f(R(auto); // equivalent to #1
>    template<class P> void f(auto(P)); // equivalent to #2
> 
> b) variadic auto
>    Once an ellipsis is seen as part of the declarator, all contained
> auto placeholders get transformed into parameter packs.
>    void f(auto (*...)(auto) -> std::tuple<auto, std::pair<auto, auto>...>);
> Note there are 4 deducible template parameter packs above.
> 
> c) multi abbreviated template declarations
>   void f(auto), g(auto);
> are allowed - the above declares two function templates.
> 
> d) template aliases desugar their types *after* each auto has been
> identified as a placeholder (and so must be deduced)
> 
>    template<class T> using Int = int;
>    Int<auto> i = 3; // Is an error, auto must be deducible.
> 
> e) generic lambda's as default arguments work with abbreviated template syntax:
>  void f(int (*)(int) = [](auto a) { return a; }, auto b = decltype(b){});
>  f<float*>(); // OK
> 
> f) variable templates and enhanced auto deduction interact as expected:
>    template<class T> pair<auto...> (*vfp)(auto...) = [](T t1, T* t2)
> { return make_pair(t1, t2); };
> 
> Thanks!
> Faisal Vali
> 
> -- 
> 
> --- 
> 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.
> Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
> 

-- 

--- 
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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

.
