220 12903 <CAOfiQq=1YOxM673VfwU7s0+z0fR2-cOqm4tbDy3YX8EsrFsczg@mail.gmail.com> article
Path: news.gmane.org!not-for-mail
From: Richard Smith <richard@metafoo.co.uk>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: unevaluated this
Date: Mon, 15 Sep 2014 15:43:11 -0700
Lines: 139
Approved: news@gmane.org
Message-ID: <CAOfiQq=1YOxM673VfwU7s0+z0fR2-cOqm4tbDy3YX8EsrFsczg@mail.gmail.com>
References: <009e6218-1e2b-402d-ab1a-e8ebf29f8f77@isocpp.org>
	<CAOfiQqmdnj2XFTvnWkd3BoFrQV8dqfeaxCn7_jKx7OT-Pkn+yQ@mail.gmail.com>
	<CAGsORuDSnYrSp0CSnCduHUNj4iEJ0ym3fenpZBmBcNrkFFCD0Q@mail.gmail.com>
	<CAOfiQqnqum7ODz_Lwav9g7fdnRJFuhDHGyfU01=gG6C5T8URsg@mail.gmail.com>
	<CAGsORuA8O=HgWVEkws4hSecUHcCr5qZFuFcDPa8EfSqxpdxSvg@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary=001a1133375c11cb350503225c92
X-Trace: ger.gmane.org 1410821005 13311 80.91.229.3 (15 Sep 2014 22:43:25 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Mon, 15 Sep 2014 22:43:25 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDVNBJG4YAIBBAGX3WQAKGQEDMLMH6Y@isocpp.org Tue Sep 16 00:43:18 2014
Return-path: <std-proposals+bncBDVNBJG4YAIBBAGX3WQAKGQEDMLMH6Y@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-qa0-f71.google.com ([209.85.216.71])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBDVNBJG4YAIBBAGX3WQAKGQEDMLMH6Y@isocpp.org>)
	id 1XTezK-0004Vq-5w
	for gclcip-std-proposals@m.gmane.org; Tue, 16 Sep 2014 00:43:14 +0200
Original-Received: by mail-qa0-f71.google.com with SMTP id k15sf12290903qaq.2
        for <gclcip-std-proposals@m.gmane.org>; Mon, 15 Sep 2014 15:43:13 -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:sender:in-reply-to:references:date
         :message-id:subject:from:to:x-original-sender
         :x-original-authentication-results:reply-to:precedence:mailing-list
         :list-id:list-post:list-help:list-archive:list-subscribe
         :list-unsubscribe:content-type;
        bh=LohwjooK+Jf3u8GapFwI6ShuZ2dVpr/yCMnLJJ2WdXQ=;
        b=gsmw3+VYfye2WvN4rzLIRVBTa1T49eV05hf+GJDgi+qmWMP6NPSctjvXNE72hSpGhA
         ks4CTkOffYGyoe85Cnh91pnVDW0D2hyUKDBRzzcKcmQaEhj8L9ytVgJX9IEyxM27yzgR
         Vj/DuR2OJNXsXh1SPxmLt2yQst5EJjG+FYx2F+NNH8dJ0tElV1ebeyoSxfmmo5CNC9Vb
         lp4f1+s4S4X4EQ+NJM0/2Q4dYRh5tS/cN33cE320I5NdZH5Mwrn5H3LfNAbbkgZ5WW1Z
         Zl3Q49x/cITQZS7+8Ff6qqy2TJzbZq7enIzcEs3tdQod4155RhNiQroHV9I66bvTRhzU
         /PKQ==
X-Gm-Message-State: ALoCoQnJ/4lUwhZfR6hYiVXjGg+p2BFLficKHottZ+B04MX4MQHUTsMr9I+G0oKwh53w3Qf9roHY
X-Received: by 10.236.8.74 with SMTP id 50mr16875700yhq.42.1410820993348;
        Mon, 15 Sep 2014 15:43:13 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.140.47.87 with SMTP id l81ls1729241qga.51.gmail; Mon, 15 Sep
 2014 15:43:12 -0700 (PDT)
X-Received: by 10.221.45.132 with SMTP id uk4mr4596500vcb.57.1410820992458;
        Mon, 15 Sep 2014 15:43:12 -0700 (PDT)
Original-Received: from mail-vc0-x22c.google.com (mail-vc0-x22c.google.com [2607:f8b0:400c:c03::22c])
        by mx.google.com with ESMTPS id f2si6896575vcy.28.2014.09.15.15.43.12
        for <std-proposals@isocpp.org>
        (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
        Mon, 15 Sep 2014 15:43:12 -0700 (PDT)
Received-SPF: pass (google.com: domain of metafoo@gmail.com designates 2607:f8b0:400c:c03::22c as permitted sender) client-ip=2607:f8b0:400c:c03::22c;
Original-Received: by mail-vc0-f172.google.com with SMTP id hy10so4127293vcb.31
        for <std-proposals@isocpp.org>; Mon, 15 Sep 2014 15:43:12 -0700 (PDT)
X-Received: by 10.221.23.66 with SMTP id qz2mr26688760vcb.46.1410820991992;
 Mon, 15 Sep 2014 15:43:11 -0700 (PDT)
Original-Sender: metafoo@gmail.com
Original-Received: by 10.220.76.200 with HTTP; Mon, 15 Sep 2014 15:43:11 -0700 (PDT)
In-Reply-To: <CAGsORuA8O=HgWVEkws4hSecUHcCr5qZFuFcDPa8EfSqxpdxSvg@mail.gmail.com>
X-Original-Sender: richard@metafoo.co.uk
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of metafoo@gmail.com designates 2607:f8b0:400c:c03::22c as permitted
 sender) smtp.mail=metafoo@gmail.com;       dkim=pass header.i=@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: <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:12903
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/12903>

--001a1133375c11cb350503225c92
Content-Type: text/plain; charset=UTF-8

On Mon, Sep 15, 2014 at 3:09 PM, Zhihao Yuan <zy@miator.net> wrote:

> On Mon, Sep 15, 2014 at 5:24 PM, Richard Smith <richard@metafoo.co.uk>
> wrote:
>
>>
>> Oops, sorry, I meant to refer to the previous proposal of
>> 'decltype(class)'. =)
>>
>
> Err, I misparsed the paper, too.
>
> Copy-pasting Ville's comment on decltype(class):
>
>   "The use of the type and value category of 'this' is already allowed in
> static member
> functions as per [expr.prim.general]/3.
>

This is only permitted as a hack: compilers don't know for sure whether
they have an out-of-line definition of a static or non-static member
function until they get to the end of the function declarator. 'this' is
permitted before then. To support this, the type and value category of
'this' are defined for a static member function, but your program is
ill-formed if it actually uses 'this' in a static member function.

Example:

struct S {
  template<typename T> auto f() -> S*;
  template<typename T> static auto f() -> const S*;
};
template<typename T> auto S::f() -> decltype(this) {}

Here, we cannot tell whether the out-of-line definition is static or not
unless we know the type of 'this'. So we define that 'this' has type 'S*'
for a static member function, and we're able to resolve the redefinition to
being the non-static function, and all is OK.

Allowing similar uses in the class definition
> has its problems, but decltype(class) likely doesn't solve those problems
> (the type may
> be incomplete because the class definition is not yet known sufficiently,
> all
> sorts of chicken-and-egg problems arise). "
>
> // and he referred you to provide more details about type completeness here
>

Class completeness should not be a problem here any more than it would be
if you named the class by its name; I don't anticipate any new problems in
that direction, but we would have a new syntax for writing the existing
problems. (I'd expect decltype(class) to be identical to naming the class
in almost all ways -- except where the class is anonymous, or its name is
hidden, or a typedef-name is disallowed etc.)

-- 

--- 
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/.

--001a1133375c11cb350503225c92
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote">On M=
on, Sep 15, 2014 at 3:09 PM, Zhihao Yuan <span dir=3D"ltr">&lt;<a href=3D"m=
ailto:zy@miator.net" target=3D"_blank">zy@miator.net</a>&gt;</span> wrote:<=
br><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;bord=
er-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:soli=
d;padding-left:1ex"><div dir=3D"ltr"><span class=3D"">On Mon, Sep 15, 2014 =
at 5:24 PM, Richard Smith <span dir=3D"ltr">&lt;<a href=3D"mailto:richard@m=
etafoo.co.uk" target=3D"_blank">richard@metafoo.co.uk</a>&gt;</span> wrote:=
<br><div class=3D"gmail_extra"><div class=3D"gmail_quote"><blockquote class=
=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left-width:1px;bo=
rder-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">=
<div dir=3D"ltr"><div class=3D"gmail_extra"><br><div class=3D"gmail_quote">=
<span></span><div>Oops, sorry, I meant to refer to the previous proposal of=
 &#39;decltype(class)&#39;. =3D)=C2=A0</div></div></div></div></blockquote>=
</div><br></div></span><div class=3D"gmail_extra">Err, I misparsed the pape=
r, too.<br><br></div><div class=3D"gmail_extra">Copy-pasting Ville&#39;s co=
mment on decltype(class):<br><br>=C2=A0 &quot;The use of the type and value=
 category of &#39;this&#39; is already allowed in static member<br>function=
s as per [expr.prim.general]/3.</div></div></blockquote><div><br></div><div=
>This is only permitted as a hack: compilers don&#39;t know for sure whethe=
r they have an out-of-line definition of a static or non-static member func=
tion until they get to the end of the function declarator. &#39;this&#39; i=
s permitted before then. To support this, the type and value category of &#=
39;this&#39; are defined for a static member function, but your program is =
ill-formed if it actually uses &#39;this&#39; in a static member function.<=
/div><div><br></div><div>Example:</div><div><br></div><div><div>struct S {<=
/div><div>=C2=A0 template&lt;typename T&gt; auto f() -&gt; S*; =C2=A0 =C2=
=A0 =C2=A0</div><div>=C2=A0 template&lt;typename T&gt; static auto f() -&gt=
; const S*;</div><div>};</div><div>template&lt;typename T&gt; auto S::f() -=
&gt; decltype(this) {}</div></div><div><br></div><div>Here, we cannot tell =
whether the out-of-line definition is static or not unless we know the type=
 of &#39;this&#39;. So we define that &#39;this&#39; has type &#39;S*&#39; =
for a static member function, and we&#39;re able to resolve the redefinitio=
n to being the non-static function, and all is OK.<br></div><div><br></div>=
<blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-=
left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;p=
adding-left:1ex"><div dir=3D"ltr"><div class=3D"gmail_extra">Allowing simil=
ar uses in the class definition<br>has its problems, but decltype(class) li=
kely doesn&#39;t solve those problems (the type may<br>be incomplete becaus=
e the class definition is not yet known sufficiently, all<br>sorts of chick=
en-and-egg problems arise). &quot;<br><br></div><div class=3D"gmail_extra">=
// and he referred you to provide more details about type completeness here=
</div></div></blockquote><div><br></div><div>Class completeness should not =
be a problem here any more than it would be if you named the class by its n=
ame; I don&#39;t anticipate any new problems in that direction, but we woul=
d have a new syntax for writing the existing problems. (I&#39;d expect decl=
type(class) to be identical to naming the class in almost all ways -- excep=
t where the class is anonymous, or its name is hidden, or a typedef-name is=
 disallowed etc.)</div></div></div></div>

<p></p>

-- <br />
<br />
--- <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 />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

--001a1133375c11cb350503225c92--

.
