220 4793 <943b7d81-5118-4dab-9ed2-017412abacc8@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: Mikhail Semenov <mikhailsemenov1957@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Changing lambda scope
Date: Sun, 2 Jun 2013 08:39:09 -0700 (PDT)
Lines: 111
Approved: news@gmane.org
Message-ID: <943b7d81-5118-4dab-9ed2-017412abacc8@isocpp.org>
References: <ae01f736-d3ac-48d6-981f-702b9ab2b3b3@isocpp.org>
 <CAFk2RUax65FEaDaeKCEdBig+bq4W4u_+39R3hsdBuyiOj-rpjA@mail.gmail.com>
 <90375ba5-8005-47da-9e84-eee151d0ba0a@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; 
	boundary="----=_Part_233_21487430.1370187549997"
X-Trace: ger.gmane.org 1370187553 20931 80.91.229.3 (2 Jun 2013 15:39:13 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Sun, 2 Jun 2013 15:39:13 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDC55PNFRYGRBH6OVWGQKGQECN3PT3I@isocpp.org Sun Jun 02 17:39:14 2013
Return-path: <std-proposals+bncBDC55PNFRYGRBH6OVWGQKGQECN3PT3I@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-gg0-f198.google.com ([209.85.161.198])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBDC55PNFRYGRBH6OVWGQKGQECN3PT3I@isocpp.org>)
	id 1UjANE-0002pP-F7
	for gclcip-std-proposals@m.gmane.org; Sun, 02 Jun 2013 17:39:12 +0200
Original-Received: by mail-gg0-f198.google.com with SMTP id p1sf3742411ggn.9
        for <gclcip-std-proposals@m.gmane.org>; Sun, 02 Jun 2013 08:39:11 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=x-beenthere:date:from:to:message-id:in-reply-to:references:subject
         :mime-version:x-original-sender:reply-to:precedence:mailing-list
         :list-id:x-google-group-id:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe:content-type;
        bh=AgxGsguEucn1o3imaqHoNLLr1m/uEQ4vplrcuBS8Zss=;
        b=ZkFrGdOFWW6lhW0vW9e7XDTaxPCmnk3VrDx1gyoxZK4x1V+diFPCfFPjUGKQy4ks1U
         omFdD5I1fORRAHZFgkcxuBKy8rbQVlzU8kGjTVtjt7Rnoec7Z3OILSl4/XNqqHtZEiUt
         3V9mXqa2oym5XRo/L2JFEQp89qmm2zxmZhylDfmkmopujOjuZOxdGahdMKhx+dG+7vj7
         ijDrSESa0WiQ53AAIqWcq1Wq8Mvt6vrN7kPTAiWAN7KxZ9e9hNFTUG5Rvs6I5vxm+lLh
         2FZx5qBM+Lb7JnnNHBWz3nJowOzh66BKddge6d2rUK/mSkUnq2nn7nph+yq+Nq05GBUS
         M6RQ==
X-Received: by 10.224.36.66 with SMTP id s2mr11717987qad.6.1370187551569;
        Sun, 02 Jun 2013 08:39:11 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.49.82.110 with SMTP id h14ls1689231qey.88.gmail; Sun, 02 Jun
 2013 08:39:10 -0700 (PDT)
X-Received: by 10.49.107.234 with SMTP id hf10mr1424577qeb.21.1370187550375;
        Sun, 02 Jun 2013 08:39:10 -0700 (PDT)
In-Reply-To: <90375ba5-8005-47da-9e84-eee151d0ba0a@isocpp.org>
X-Original-Sender: mikhailsemenov1957@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:4793
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/4793>

------=_Part_233_21487430.1370187549997
Content-Type: text/plain; charset=ISO-8859-1

This is not exactly what you wanted, but the following works:
 
#include <iostream>
#include <functional>
namespace range 
{
    template<typename R, typename L> auto operator|(L l, R r) -> L
    {
         return l+r;        
    }
    template<typename T> auto map(T t) //-> std::function<int(bool)> // GCC 
4.8.0 accepts without the result type
    {
        return [=](bool range) -> int
        {
            if (range) return t.i;
            return 0;
        };
    }
}
struct A
{
   int i;
   A(int i1):i(i1) {}
};
int main() 
{
    int something = 10;
    A a1(5);
    A a2(6);
    int k =
    something
        | range::map(a1)(true)
        | range::map(a2)(false);
    std::cout << k << std::endl; // 15 is the printed result       
}


 

> It's part of a range design I am working on. I have implemented everything 
> I need but the lambda ADL problem means that I can't use lambdas when I 
> should be able to, because the range-combine operator| can't be found.
>

-- 

--- 
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.



------=_Part_233_21487430.1370187549997
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<div>This is not exactly what you wanted, but the following works:</div><di=
v>&nbsp;</div><div><font face=3D"courier new,monospace">#include &lt;iostre=
am&gt;<br>#include &lt;functional&gt;</font></div><div><font face=3D"courie=
r new,monospace">namespace range <br>{<br>&nbsp;&nbsp;&nbsp; template&lt;ty=
pename R, typename L&gt; auto operator|(L l, R r) -&gt; L<br>&nbsp;&nbsp;&n=
bsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return l+r;&nbsp=
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nb=
sp;&nbsp; template&lt;typename T&gt; auto map(T t) //-&gt; std::function&lt=
;int(bool)&gt; // GCC 4.8.0 accepts without&nbsp;the result&nbsp;type<br>&n=
bsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return [=
=3D](bool range) -&gt; int<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<=
br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (r=
ange) return t.i;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp; return 0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; };<br>=
&nbsp;&nbsp;&nbsp; }<br>}</font></div><div><font face=3D"courier new,monosp=
ace">struct A<br>{<br>&nbsp;&nbsp; int i;<br>&nbsp;&nbsp; A(int i1):i(i1) {=
}<br>};</font></div><div><font face=3D"courier new,monospace">int main() <b=
r>{<br>&nbsp;&nbsp;&nbsp; int something =3D 10;<br>&nbsp;&nbsp;&nbsp; A a1(=
5);<br>&nbsp;&nbsp;&nbsp; A a2(6);<br>&nbsp;&nbsp;&nbsp; int k =3D<br>&nbsp=
;&nbsp;&nbsp; something<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | ran=
ge::map(a1)(true)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | range::ma=
p(a2)(false);<br>&nbsp;&nbsp;&nbsp; std::cout &lt;&lt; k &lt;&lt; std::endl=
;&nbsp;// 15 is the printed result&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>=
}</font></div><div><br><br>&nbsp;</div><blockquote class=3D"gmail_quote" st=
yle=3D"margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left-color: rgb=
(204, 204, 204); border-left-width: 1px; border-left-style: solid;"><div>It=
's part of a range design I am working on. I have implemented everything I =
need but the lambda ADL problem means that I can't use lambdas when I shoul=
d be able to, because the range-combine operator| can't be found.</div></bl=
ockquote>

<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 />

------=_Part_233_21487430.1370187549997--

.
