220 4797 <CAOfiQqnBRs1ubkGsZw71QZ33KiN99yuCD2M7tcG9hzanudWVqw@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: Re: Changing lambda scope
Date: Sun, 2 Jun 2013 15:49:26 -0700
Lines: 142
Approved: news@gmane.org
Message-ID: <CAOfiQqnBRs1ubkGsZw71QZ33KiN99yuCD2M7tcG9hzanudWVqw@mail.gmail.com>
References: <ae01f736-d3ac-48d6-981f-702b9ab2b3b3@isocpp.org>
	<ee935af8-a586-4898-9042-9ef04d909cfa@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary=089e013cc328fd9c2004de33a845
X-Trace: ger.gmane.org 1370213371 31776 80.91.229.3 (2 Jun 2013 22:49:31 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Sun, 2 Jun 2013 22:49:31 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDVNBJG4YAIBB54XV6GQKGQED25R3SA@isocpp.org Mon Jun 03 00:49:29 2013
Return-path: <std-proposals+bncBDVNBJG4YAIBB54XV6GQKGQED25R3SA@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-vb0-f69.google.com ([209.85.212.69])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBDVNBJG4YAIBB54XV6GQKGQED25R3SA@isocpp.org>)
	id 1UjH5d-0007zq-1p
	for gclcip-std-proposals@m.gmane.org; Mon, 03 Jun 2013 00:49:29 +0200
Original-Received: by mail-vb0-f69.google.com with SMTP id p13sf4593184vbe.4
        for <gclcip-std-proposals@m.gmane.org>; Sun, 02 Jun 2013 15:49:28 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=x-beenthere: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:x-google-group-id:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe:content-type;
        bh=A9/+tiZQxeTdP/eIsBY3HobOjI2Yw7d1QUwjDlClZ2s=;
        b=lrKY/UnHpiNbjh8aV7cF9gDpa9WbgOsw/Bn5wK6uQm1lRjTCZ3OKKJlhDwQHbeq6s6
         leHAQyzgXdsc/xk8mb/VvWPWXQ4Xz9XJtyD+eOVWiEjU8mxZGr0aSwe973U5eq2/vCWX
         sgVttOsDAV49noTe0zoTe1Qp9mAZiookHqyUfmA/21X/xNq6HmFxts6KCzSNWlGgP/Pl
         JFlYUPopIjKbOnsOMjGM+rUhX3zMe8VG6OzBTzP1I/uBdhmK989Dnj4eHLgERS18bk3u
         hb88VUNnVLuNySa6CFN2GsiG7qQrVc4ZJsO0c14iBNytYrd8jTRB7CNXcBvlYU26ScYN
         mTdA==
X-Received: by 10.224.3.131 with SMTP id 3mr12547581qan.5.1370213368021;
        Sun, 02 Jun 2013 15:49:28 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.49.48.4 with SMTP id h4ls1832602qen.50.gmail; Sun, 02 Jun 2013
 15:49:27 -0700 (PDT)
X-Received: by 10.220.191.129 with SMTP id dm1mr16062418vcb.54.1370213366968;
        Sun, 02 Jun 2013 15:49:26 -0700 (PDT)
Original-Received: from mail-ve0-x236.google.com (mail-ve0-x236.google.com [2607:f8b0:400c:c01::236])
        by mx.google.com with ESMTPS id iz8si34189671vdb.97.2013.06.02.15.49.26
        for <std-proposals@isocpp.org>
        (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
        Sun, 02 Jun 2013 15:49:26 -0700 (PDT)
Received-SPF: pass (google.com: domain of metafoo@gmail.com designates 2607:f8b0:400c:c01::236 as permitted sender) client-ip=2607:f8b0:400c:c01::236;
Original-Received: by mail-ve0-f182.google.com with SMTP id ox1so2382306veb.13
        for <std-proposals@isocpp.org>; Sun, 02 Jun 2013 15:49:26 -0700 (PDT)
X-Received: by 10.58.45.71 with SMTP id k7mr16314969vem.0.1370213366731; Sun,
 02 Jun 2013 15:49:26 -0700 (PDT)
Original-Sender: metafoo@gmail.com
Original-Received: by 10.58.246.226 with HTTP; Sun, 2 Jun 2013 15:49:26 -0700 (PDT)
In-Reply-To: <ee935af8-a586-4898-9042-9ef04d909cfa@isocpp.org>
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:c01::236 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?hl=en>,
 <mailto:std-proposals@isocpp.org>
List-Help: <http://support.google.com/a/isocpp.org/bin/topic.py?hl=en&topic=25838>,
 <mailto:std-proposals+help@isocpp.org>
List-Archive: <http://groups.google.com/a/isocpp.org/group/std-proposals/?hl=en>
List-Subscribe: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe?hl=en>,
 <mailto:std-proposals+subscribe@isocpp.org>
List-Unsubscribe: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe?hl=en>,
 <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:4797
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/4797>

--089e013cc328fd9c2004de33a845
Content-Type: text/plain; charset=ISO-8859-1

On Sun, Jun 2, 2013 at 11:12 AM, Mikhail Semenov <
mikhailsemenov1957@gmail.com> wrote:

> And the following code works. I think auto may be the problem.
>>
> #include <iostream>
> #include <functional>
> bool ok = true;
> namespace range
> {
>     template<typename R, typename L> auto operator|(L l, R r) // -> int
>     {
>          return l(ok)+r(ok);
>     }
>     template<typename T> auto map(T t) //-> std::function<int(bool)>
>     {
>         return [=](bool range) -> int
>         {
>             if (range) return t.i;
>             return 0;
>         };
>     }
> }
> struct A
> {
>    int i;
>    A(int i1):i(i1) {}
> };
>
> int main()
> {
>     A a1(5);
>     A a2(6);
>     int k =
>         range::map(a1)
>         | range::map(a2);
>     std::cout << k << std::endl;  // 11
>     ok = false;
>
>     k =
>         range::map(a1)
>         | range::map(a2);
>     std::cout << k << std::endl;  // 0
>
> }
>

This does not compile in Clang:

<stdin>:31:9: error: invalid operands to binary expression ('<lambda at
<stdin>:12:16>' and '<lambda at <stdin>:12:16>')
        | range::map(a2);
        ^ ~~~~~~~~~~~~~~
<stdin>:37:9: error: invalid operands to binary expression ('<lambda at
<stdin>:12:16>' and '<lambda at <stdin>:12:16>')
        | range::map(a2);
        ^ ~~~~~~~~~~~~~~

It appears that g++ includes the enclosing namespaces as associated
namespaces for local classes, contrary to the current rules in the standard.

-- 

--- 
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/?hl=en.



--089e013cc328fd9c2004de33a845
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

On Sun, Jun 2, 2013 at 11:12 AM, Mikhail Semenov <span dir=3D"ltr">&lt;<a h=
ref=3D"mailto:mikhailsemenov1957@gmail.com" target=3D"_blank">mikhailsemeno=
v1957@gmail.com</a>&gt;</span> wrote:<br><div class=3D"gmail_quote"><blockq=
uote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc =
solid;padding-left:1ex">
<blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;padding=
-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-l=
eft-style:solid"><div>And the following code works. I think auto may be the=
 problem.</div>
</blockquote><div><font face=3D"courier new,monospace">#include &lt;iostrea=
m&gt;<br>#include &lt;functional&gt;</font></div><div><font face=3D"courier=
 new,monospace">bool ok =3D true;<br>namespace range <br>{<br>=A0=A0=A0 tem=
plate&lt;typename R, typename L&gt; auto operator|(L l, R r) // -&gt; int<b=
r>
=A0=A0=A0 {<br>=A0=A0=A0=A0=A0=A0=A0=A0 return l(ok)+r(ok);=A0=A0=A0=A0=A0=
=A0=A0 <br><div class=3D"im">=A0=A0=A0 }<br>=A0=A0=A0 template&lt;typename =
T&gt; auto map(T t) //-&gt; std::function&lt;int(bool)&gt;<br></div><div cl=
ass=3D"im">=A0=A0=A0 {<br>=A0=A0=A0=A0=A0=A0=A0 return [=3D](bool range) -&=
gt; int<br>
=A0=A0=A0=A0=A0=A0=A0 {<br>=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 if (range) ret=
urn t.i;<br>=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 return 0;<br>=A0=A0=A0=A0=A0=
=A0=A0 };<br>=A0=A0=A0 }<br>}</div></font></div><div class=3D"im"><div><fon=
t face=3D"courier new,monospace">struct A<br>{<br>=A0=A0 int i;<br>=A0=A0 A=
(int i1):i(i1) {}<br>
};</font></div></div><div><br><font face=3D"courier new,monospace">int main=
() <br>{=A0=A0=A0 <br><div class=3D"im">=A0=A0=A0 A a1(5);<br>=A0=A0=A0 A a=
2(6);<br>=A0=A0=A0 int k =3D<br></div>=A0=A0=A0=A0=A0=A0=A0 range::map(a1)<=
br>=A0=A0=A0=A0=A0=A0=A0 | range::map(a2);<br>=A0=A0=A0 std::cout &lt;&lt; =
k &lt;&lt; std::endl;=A0 // 11=A0=A0=A0=A0=A0 <br>
=A0=A0=A0 ok =3D false;<br>=A0=A0=A0 <br>=A0=A0=A0 k =3D<br>=A0=A0=A0=A0=A0=
=A0=A0 range::map(a1)<br>=A0=A0=A0=A0=A0=A0=A0 | range::map(a2);<br>=A0=A0=
=A0 std::cout &lt;&lt; k &lt;&lt; std::endl;=A0 // 0=A0=A0=A0=A0=A0 <br>=A0=
=A0=A0 <br>}</font></div></blockquote><div><br></div><div>This does not com=
pile in Clang:</div>
<div><br></div><div><div>&lt;stdin&gt;:31:9: error: invalid operands to bin=
ary expression (&#39;&lt;lambda at &lt;stdin&gt;:12:16&gt;&#39; and &#39;&l=
t;lambda at &lt;stdin&gt;:12:16&gt;&#39;)</div><div>=A0 =A0 =A0 =A0 | range=
::map(a2);</div>
<div>=A0 =A0 =A0 =A0 ^ ~~~~~~~~~~~~~~</div><div>&lt;stdin&gt;:37:9: error: =
invalid operands to binary expression (&#39;&lt;lambda at &lt;stdin&gt;:12:=
16&gt;&#39; and &#39;&lt;lambda at &lt;stdin&gt;:12:16&gt;&#39;)</div><div>=
=A0 =A0 =A0 =A0 | range::map(a2);</div>
<div>=A0 =A0 =A0 =A0 ^ ~~~~~~~~~~~~~~</div></div><div><br></div><div>It app=
ears that g++ includes the enclosing namespaces as associated namespaces fo=
r local classes, contrary to the current rules in the standard.</div></div>

<p></p>

-- <br />
&nbsp;<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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
&nbsp;<br />
&nbsp;<br />

--089e013cc328fd9c2004de33a845--

.
