220 4805 <CAMeU-s0Tj8eskMNuRy-GkcqgKWWuTMV+Vn-NS1DcX7c=xonqGw@mail.gmail.com> article
Path: news.gmane.org!not-for-mail
From: Mikhail Semenov <mikhailsemenov1957@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Re: Changing lambda scope
Date: Mon, 3 Jun 2013 08:56:57 +0100
Lines: 200
Approved: news@gmane.org
Message-ID: <CAMeU-s0Tj8eskMNuRy-GkcqgKWWuTMV+Vn-NS1DcX7c=xonqGw@mail.gmail.com>
References: <ae01f736-d3ac-48d6-981f-702b9ab2b3b3@isocpp.org>
	<ee935af8-a586-4898-9042-9ef04d909cfa@isocpp.org>
	<CAOfiQqnBRs1ubkGsZw71QZ33KiN99yuCD2M7tcG9hzanudWVqw@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary=089e0118403e161dcd04de3b4f31
X-Trace: ger.gmane.org 1370246221 19200 80.91.229.3 (3 Jun 2013 07:57:01 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Mon, 3 Jun 2013 07:57:01 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDC55PNFRYGRBS4YWGGQKGQETCY466A@isocpp.org Mon Jun 03 09:57:01 2013
Return-path: <std-proposals+bncBDC55PNFRYGRBS4YWGGQKGQETCY466A@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-ob0-f199.google.com ([209.85.214.199])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBDC55PNFRYGRBS4YWGGQKGQETCY466A@isocpp.org>)
	id 1UjPdV-0002P1-7Z
	for gclcip-std-proposals@m.gmane.org; Mon, 03 Jun 2013 09:57:01 +0200
Original-Received: by mail-ob0-f199.google.com with SMTP id xk17sf22907980obc.10
        for <gclcip-std-proposals@m.gmane.org>; Mon, 03 Jun 2013 00:57:00 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=x-beenthere:mime-version: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=Al9mZegqHXLMrnLLA8Eav2/3hjWLH/tjVB/cc+fM7+U=;
        b=RmywAikYr4KrtUd/6hs5vp31/a854BBrH+CIBUlD7gUaIPcqvllhKsvNw2vj58Ft2M
         36e7AhdGmGAynCpdN8R5arFP66l8ZhRjG6rnNtU85YYwnzJM8zy1JC5oiI5zww6DRYr3
         lOefPpUiX+Az/F1r4hvk6cO/XGqYRFyOIYkiyyhwTamhCVwzlp2rCpA8Y0Wq5y1lseGP
         UolrtxZP08DfzbHMJo4Pni0BNqSyEVcsyFyW7PGJjEYBEvzw+5vJLIxKVY92eHkDpy+u
         vXg28XuXCEoYZlEAw542RX7VUNJwxSpDnXpu7eC8MmNLWovsRlAd8Dz6wK4QXITPme/0
         vzYg==
X-Received: by 10.182.236.231 with SMTP id ux7mr5083429obc.5.1370246220209;
        Mon, 03 Jun 2013 00:57:00 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.182.117.233 with SMTP id kh9ls182709obb.17.gmail; Mon, 03 Jun
 2013 00:56:58 -0700 (PDT)
X-Received: by 10.60.160.161 with SMTP id xl1mr7323417oeb.84.1370246218292;
        Mon, 03 Jun 2013 00:56:58 -0700 (PDT)
Original-Received: from mail-ob0-x233.google.com (mail-ob0-x233.google.com [2607:f8b0:4003:c01::233])
        by mx.google.com with ESMTPS id i7si13323894oef.53.2013.06.03.00.56.58
        for <std-proposals@isocpp.org>
        (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
        Mon, 03 Jun 2013 00:56:58 -0700 (PDT)
Received-SPF: pass (google.com: domain of mikhailsemenov1957@gmail.com designates 2607:f8b0:4003:c01::233 as permitted sender) client-ip=2607:f8b0:4003:c01::233;
Original-Received: by mail-ob0-f179.google.com with SMTP id xk17so6608133obc.38
        for <std-proposals@isocpp.org>; Mon, 03 Jun 2013 00:56:58 -0700 (PDT)
X-Received: by 10.60.83.73 with SMTP id o9mr3640577oey.137.1370246218127; Mon,
 03 Jun 2013 00:56:58 -0700 (PDT)
Original-Received: by 10.60.20.170 with HTTP; Mon, 3 Jun 2013 00:56:57 -0700 (PDT)
In-Reply-To: <CAOfiQqnBRs1ubkGsZw71QZ33KiN99yuCD2M7tcG9hzanudWVqw@mail.gmail.com>
X-Original-Sender: mikhailsemenov1957@gmail.com
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of mikhailsemenov1957@gmail.com designates 2607:f8b0:4003:c01::233 as
 permitted sender) smtp.mail=mikhailsemenov1957@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:4805
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/4805>

--089e0118403e161dcd04de3b4f31
Content-Type: text/plain; charset=ISO-8859-1

Richard,

Have you tried to uncomment the return type?
That might be the problem.

Mikhail.

On 2 June 2013 23:49, Richard Smith <richard@metafoo.co.uk> wrote:

>  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.
>
>
>

-- 

--- 
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.



--089e0118403e161dcd04de3b4f31
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<div>Richard,</div>
<div>=A0</div>
<div>Have you tried to uncomment the return type?</div>
<div>That might be the problem.</div>
<div>=A0</div>
<div>Mikhail.<br><br></div>
<div class=3D"gmail_quote">On 2 June 2013 23:49, Richard Smith <span dir=3D=
"ltr">&lt;<a href=3D"mailto:richard@metafoo.co.uk" target=3D"_blank">richar=
d@metafoo.co.uk</a>&gt;</span> wrote:<br>
<blockquote style=3D"BORDER-LEFT:#ccc 1px solid;MARGIN:0px 0px 0px 0.8ex;PA=
DDING-LEFT:1ex" class=3D"gmail_quote">
<div class=3D"HOEnZb">
<div class=3D"h5">On Sun, Jun 2, 2013 at 11:12 AM, Mikhail Semenov <span di=
r=3D"ltr">&lt;<a href=3D"mailto:mikhailsemenov1957@gmail.com" target=3D"_bl=
ank">mikhailsemenov1957@gmail.com</a>&gt;</span> wrote:<br></div></div>
<div class=3D"gmail_quote">
<div>
<div class=3D"h5">
<blockquote style=3D"BORDER-LEFT:#ccc 1px solid;MARGIN:0px 0px 0px 0.8ex;PA=
DDING-LEFT:1ex" class=3D"gmail_quote">
<blockquote style=3D"BORDER-LEFT:rgb(204,204,204) 1px solid;MARGIN:0px 0px =
0px 0.8ex;PADDING-LEFT:1ex" class=3D"gmail_quote">
<div>And the following code works. I think auto may be the problem.</div></=
blockquote>
<div><font face=3D"courier new,monospace">#include &lt;iostream&gt;<br>#inc=
lude &lt;functional&gt;</font></div>
<div><font face=3D"courier new,monospace">bool ok =3D true;<br>namespace ra=
nge <br>{<br>=A0=A0=A0 template&lt;typename R, typename L&gt; auto operator=
|(L l, R r) // -&gt; int<br>=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>=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>=A0=A0=A0 {<br>=A0=A0=A0=A0=A0=A0=A0 return [=3D](bool range) -&gt; in=
t<br>=A0=A0=A0=A0=A0=A0=A0 {<br>=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 if (range=
) return 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>
<div><font 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>=A0=A0=A0 A a1(5);<br>=A0=A0=A0 A a2(6);<br>=A0=A0=A0 int k =3D<br></d=
iv>=A0=A0=A0=A0=A0=A0=A0 range::map(a1)<br>=A0=A0=A0=A0=A0=A0=A0 | range::m=
ap(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<b=
r>=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></div>
<div>This does not compile in Clang:</div>
<div><br></div>
<div>
<div>&lt;stdin&gt;:31:9: error: invalid operands to binary expression (&#39=
;&lt;lambda at &lt;stdin&gt;:12:16&gt;&#39; and &#39;&lt;lambda at &lt;stdi=
n&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;stdi=
n&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 appears that g++ includes the enclosing namespaces as associated na=
mespaces for local classes, contrary to the current rules in the standard.<=
/div></div>
<div class=3D"HOEnZb">
<div class=3D"h5">
<p></p>-- <br>=A0<br>--- <br>You received this message because you are subs=
cribed 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 email to <a href=3D"mailto:std-proposals%2Bunsubscribe@isocpp.org=
" target=3D"_blank">std-proposals+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br>Visit this group a=
t <a href=3D"http://groups.google.com/a/isocpp.org/group/std-proposals/?hl=
=3Den" target=3D"_blank">http://groups.google.com/a/isocpp.org/group/std-pr=
oposals/?hl=3Den</a>.<br>
=A0<br>=A0<br></div></div></blockquote></div><br>

<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 />

--089e0118403e161dcd04de3b4f31--

.
