220 21981 <CANu6V4U0mJamLMmdNs3ssrDnRBLXAFWJP454cwSmMu-fuo0VDA@mail.gmail.com> article
Path: news.gmane.org!not-for-mail
From: "'Johannes Schaub' via ISO C++ Standard - Future Proposals" <std-proposals@isocpp.org>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Re: Functions whose body is an expression
Date: Sun, 25 Oct 2015 21:03:13 +0100
Lines: 48
Approved: news@gmane.org
Message-ID: <CANu6V4U0mJamLMmdNs3ssrDnRBLXAFWJP454cwSmMu-fuo0VDA@mail.gmail.com>
References: <CANu6V4XE5+LXsPgpKAkBsSLo4hUkx36OLYkyS6J4npGZnqWKXQ@mail.gmail.com>
	<cb036934-e7db-401f-8e26-5ff4368bad42@isocpp.org>
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 1445803401 25651 80.91.229.3 (25 Oct 2015 20:03:21 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Sun, 25 Oct 2015 20:03:21 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCQPNCEZSQNBBAXLWSYQKGQETRAK7EI@isocpp.org Sun Oct 25 21:03:17 2015
Return-path: <std-proposals+bncBCQPNCEZSQNBBAXLWSYQKGQETRAK7EI@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-lf0-f71.google.com ([209.85.215.71])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBCQPNCEZSQNBBAXLWSYQKGQETRAK7EI@isocpp.org>)
	id 1ZqRVd-0000ay-6t
	for gclcip-std-proposals@m.gmane.org; Sun, 25 Oct 2015 21:03:17 +0100
Original-Received: by lfaz124 with SMTP id z124sf70004083lfa.0
        for <gclcip-std-proposals@m.gmane.org>; Sun, 25 Oct 2015 13:03:16 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:mime-version:in-reply-to:references:date
         :message-id:subject:from:to:content-type: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=UarHFBmMvYFWETPRJGnfagkBQBy7fqVb2E1WVRPeGZU=;
        b=X2lNxCICMQ4FiZYnolo8DCT4JljToslGJfI4is8njbSzxmMq7GgEPt3FI8LEcgSphj
         OnnpNkGxvd7ePklOBrnx7TKkVbUNDXHW+dl9woLjuHanPb+hA9dzRaoKC4HGak0pecbg
         RAaMuIyOxlwjp+zklNjisYXV5aE2uEmEIbNjcOEqUdj1fVo7Hfc3wZdG1chxA1Ubjdoi
         1r14mBwUaSgBfr0RsFrqbMGZSEUA1doKEB06Ki1+usxV+vUaA1K7zmLwcD1d3MDPX3C0
         8Ei51Ak7is6BdtxQ22e91A7lgefxi6VsYMm6QlNPFShnti+gd2GGYJA/h3+SzxioYjOV
         ui4g==
X-Gm-Message-State: ALoCoQmlQU59SXURmiPbchYifhK1+4bznS68euJHrLgnfxVwFW1C/aRxA4QK8Xnte6joqsFhbpIR
X-Received: by 10.28.211.201 with SMTP id k192mr340842wmg.3.1445803396679;
        Sun, 25 Oct 2015 13:03:16 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.25.25.67 with SMTP id 64ls600693lfz.41.gmail; Sun, 25 Oct 2015
 13:03:14 -0700 (PDT)
X-Received: by 10.112.151.37 with SMTP id un5mr1224107lbb.53.1445803394283;
        Sun, 25 Oct 2015 13:03:14 -0700 (PDT)
Original-Received: from mail-lf0-x233.google.com (mail-lf0-x233.google.com. [2a00:1450:4010:c07::233])
        by mx.google.com with ESMTPS id mt6si18760549lbb.32.2015.10.25.13.03.14
        for <std-proposals@isocpp.org>
        (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Sun, 25 Oct 2015 13:03:14 -0700 (PDT)
Received-SPF: pass (google.com: domain of schaub.johannes@googlemail.com designates 2a00:1450:4010:c07::233 as permitted sender) client-ip=2a00:1450:4010:c07::233;
Original-Received: by lffz202 with SMTP id z202so127963999lff.3
        for <std-proposals@isocpp.org>; Sun, 25 Oct 2015 13:03:13 -0700 (PDT)
X-Received: by 10.25.22.38 with SMTP id m38mr10075869lfi.10.1445803393523;
 Sun, 25 Oct 2015 13:03:13 -0700 (PDT)
Original-Received: by 10.112.74.132 with HTTP; Sun, 25 Oct 2015 13:03:13 -0700 (PDT)
In-Reply-To: <cb036934-e7db-401f-8e26-5ff4368bad42@isocpp.org>
X-Original-Sender: schaub.johannes@googlemail.com
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of schaub.johannes@googlemail.com designates 2a00:1450:4010:c07::233
 as permitted sender) smtp.mailfrom=schaub.johannes@googlemail.com;
       dkim=pass header.i=@googlemail.com;       dmarc=pass (p=QUARANTINE
 dis=NONE) header.from=googlemail.com
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Spam-Checked-In-Group: 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>
X-Original-From: Johannes Schaub <schaub.johannes@googlemail.com>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:21981
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/21981>

2015-10-25 18:32 GMT+01:00 Nicol Bolas <jmckesson@gmail.com>:
>
>
> On Sunday, October 25, 2015 at 10:42:50 AM UTC-4, Johannes Schaub wrote:
>>
>> Hello all, my proposal is to allow an initializer (expression) as function
>> body
>>
>>    int abs(int x) = x > 0 ? x : -x;
>>
>> Or, (with support of SFINAE and overloadability!)
>>
>>     template<typename T> auto size(T &&t)  = t.sizte();
>>     template<typename T> auto size(T &&t)  = t.count();
>>     template<typename T> auto size(T &&t)  = t.length();
>
>
> First, that's not overloading, since SFINAE makes the other declarations
> disappear. And if it doesn't, you get a straight-up compilation error. That
> is, you can't pass a `T` that has both `size` and `count`.
>

Well, this is overloading. But not overload resolution (to be
hairsplitting, it's like 5% overload resolution because a candidate
set is still formed..).

> Second, this would be better done with concepts, since the concept would
> make it much more obvious what's going on:
>
> auto size(HasSize &&t) {return t.size();}
> auto size(HasCount &&t) {return t.count();}
> auto size(HasLength &&t) {return t.length();}
>
> Also, such concepts would be a lot more specific. Rather than checking a
> single member function or something, they'd be based on things like
> `Container` or whatever.
>

This is a good point. Sufficient to make me forget about this. Thanks!

-- 

--- 
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/.

.
