220 18015 <53EE4B7E-4B59-4464-B02B-57DEE89A86A1@gmail.com> article
Path: news.gmane.org!not-for-mail
From: David Krauss <potswa@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: First draft: Non-copyable call wrapper, std::unique_function
Date: Wed, 20 May 2015 09:53:42 +0800
Lines: 109
Approved: news@gmane.org
Message-ID: <53EE4B7E-4B59-4464-B02B-57DEE89A86A1@gmail.com>
References: <59ED9069-2650-44E2-B00E-0E56ED37B83D@gmail.com> <27a788e7-4912-4a58-8201-79138ddf15a3@isocpp.org> <CAGg_6+P=2BDzGGugjdAx1pKsAHxuxNyEXGi3rz-CA-st32mf0Q@mail.gmail.com> <CANh8DEm-a_JJUCOH=g6E9bKC=qN+cwV=xJm54boqhKmGKn2xRQ@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2098\))
Content-Type: multipart/alternative; boundary="Apple-Mail=_9AA3278A-698B-488F-BA75-CF628664B6CA"
X-Trace: ger.gmane.org 1432086834 26836 80.91.229.3 (20 May 2015 01:53:54 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Wed, 20 May 2015 01:53:54 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCW25A7E3QCRBL6S56VAKGQE5XYXUVY@isocpp.org Wed May 20 03:53:53 2015
Return-path: <std-proposals+bncBCW25A7E3QCRBL6S56VAKGQE5XYXUVY@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+bncBCW25A7E3QCRBL6S56VAKGQE5XYXUVY@isocpp.org>)
	id 1YutCj-00076y-CA
	for gclcip-std-proposals@m.gmane.org; Wed, 20 May 2015 03:53:53 +0200
Original-Received: by obbkp3 with SMTP id kp3sf47813858obb.0
        for <gclcip-std-proposals@m.gmane.org>; Tue, 19 May 2015 18:53:52 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:from:content-type:message-id:mime-version
         :subject:date:references:to:in-reply-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;
        bh=3aKX4eVcES2lczdq3dvyPIf/5ya3cDu4eZ8iwAl7GEk=;
        b=Ssvzb4owOpsMCRJCu1Q+RYD8/ypJPbhYCJYQV/ggyyN7U8eMtpsOmlmrYYukNGEoIZ
         YVwNRkaWkiUYlyEXP3luJTJQ85Q5nX2WvNNl8S74BWffGwQd0skKm/jEJVzbmXp7TEQl
         DYsShseHH9uEqlF2XZaEtYqp+SSQub7wSzNlZvlEUWnriYnT5v5I9o06MZQ2GHfvlob2
         pvK2vN9LFG9offofKJllGLtB2i3rgKsRxc8UdidYQiJfQRi00ojfwVUQqLcEAfFARcTy
         /QuSFFe4v7mkozkUrRzo2CbtDZbwXaEFyBdYlDjfufhW/J+UWodoOk//TigipDJFY1/7
         sDvA==
X-Gm-Message-State: ALoCoQlbKOPxvX355LQrI1kgnEOm4bICJ0YMuubj9y/KYlHsvdrBcMKP9zMEGvyugvCmPqxSeM5F
X-Received: by 10.50.128.231 with SMTP id nr7mr29303335igb.11.1432086832197;
        Tue, 19 May 2015 18:53:52 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.182.18.39 with SMTP id t7ls248713obd.85.gmail; Tue, 19 May
 2015 18:53:51 -0700 (PDT)
X-Received: by 10.60.175.72 with SMTP id by8mr27240802oec.35.1432086831355;
        Tue, 19 May 2015 18:53:51 -0700 (PDT)
Original-Received: from mail-oi0-x22a.google.com (mail-oi0-x22a.google.com. [2607:f8b0:4003:c06::22a])
        by mx.google.com with ESMTPS id gu7si9680983obb.95.2015.05.19.18.53.51
        for <std-proposals@isocpp.org>
        (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Tue, 19 May 2015 18:53:51 -0700 (PDT)
Received-SPF: pass (google.com: domain of potswa@gmail.com designates 2607:f8b0:4003:c06::22a as permitted sender) client-ip=2607:f8b0:4003:c06::22a;
Original-Received: by oihb9 with SMTP id b9so25236377oih.3
        for <std-proposals@isocpp.org>; Tue, 19 May 2015 18:53:51 -0700 (PDT)
X-Received: by 10.202.220.135 with SMTP id t129mr17665494oig.115.1432086830825;
        Tue, 19 May 2015 18:53:50 -0700 (PDT)
Original-Received: from [172.20.10.2] ([121.54.44.91])
        by mx.google.com with ESMTPSA id y19sm9296312oie.13.2015.05.19.18.53.47
        for <std-proposals@isocpp.org>
        (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
        Tue, 19 May 2015 18:53:49 -0700 (PDT)
In-Reply-To: <CANh8DEm-a_JJUCOH=g6E9bKC=qN+cwV=xJm54boqhKmGKn2xRQ@mail.gmail.com>
X-Mailer: Apple Mail (2.2098)
X-Original-Sender: potswa@gmail.com
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of potswa@gmail.com designates 2607:f8b0:4003:c06::22a as permitted
 sender) smtp.mail=potswa@gmail.com;       dkim=pass header.i=@gmail.com;
       dmarc=pass (p=NONE dis=NONE) header.from=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:18015
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/18015>

--Apple-Mail=_9AA3278A-698B-488F-BA75-CF628664B6CA
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=UTF-8


> On 2015=E2=80=9305=E2=80=9320, at 1:52 AM, 'Matt Calabrese' via ISO C++ S=
tandard - Future Proposals <std-proposals@isocpp.org <mailto:std-proposals@=
isocpp.org>> wrote:
>=20
> On Tue, May 19, 2015 at 10:49 AM, Nevin Liber <nevin@eviloverlord.com <ma=
ilto:nevin@eviloverlord.com>> wrote:
> Also, consider making unique_function(unique_function&&) noexcept.
>=20
> +1 for noexcept, and it should be able to avoid calling the move construc=
tor when in remote storage (forcing remote storage if the underlying object=
 has a move constructor that can throw)

That=E2=80=99s an idea. I don=E2=80=99t know if it=E2=80=99s worth it, but =
I=E2=80=99ll add it as a note.

The idea would apply to std::function just as well.

The main problem is that most explicitly-defined move constructors in pract=
ice aren=E2=80=99t noexcept, just because people forget. On the other hand,=
 most classes with an explicitly-defined move constructor (or composed from=
 something with one) are big enough that the in-wrapper storage optimizatio=
n won=E2=80=99t apply anyway.

Also, another corner case: the move constructor will allocate memory when t=
he source has a non-POCMA (allocator_traits::propagate_on_container_move_as=
signment) allocator. I=E2=80=99m not really seeing an exception-safety guar=
antee being feasible.

--=20

---=20
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 e=
mail 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-proposa=
ls/.

--Apple-Mail=_9AA3278A-698B-488F-BA75-CF628664B6CA
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=UTF-8

<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dutf-8"><meta http-equiv=3D"Content-Type" content=3D"text/html charset=3D=
utf-8"><meta http-equiv=3D"Content-Type" content=3D"text/html charset=3Dutf=
-8"><meta http-equiv=3D"Content-Type" content=3D"text/html charset=3Dutf-8"=
><meta http-equiv=3D"Content-Type" content=3D"text/html charset=3Dutf-8"><m=
eta http-equiv=3D"Content-Type" content=3D"text/html charset=3Dutf-8"><meta=
 http-equiv=3D"Content-Type" content=3D"text/html charset=3Dutf-8"><meta ht=
tp-equiv=3D"Content-Type" content=3D"text/html charset=3Dutf-8"><meta http-=
equiv=3D"Content-Type" content=3D"text/html charset=3Dutf-8"></head><body s=
tyle=3D"word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break=
: after-white-space;" class=3D""><br class=3D""><div class=3D""><blockquote=
 type=3D"cite" class=3D""><div class=3D"">On 2015=E2=80=9305=E2=80=9320, at=
 1:52 AM, 'Matt Calabrese' via ISO C++ Standard - Future Proposals &lt;<a h=
ref=3D"mailto:std-proposals@isocpp.org" class=3D"">std-proposals@isocpp.org=
</a>&gt; wrote:</div><br class=3D"Apple-interchange-newline"><div class=3D"=
"><div dir=3D"ltr" class=3D""><div class=3D"gmail_extra"><div class=3D"gmai=
l_quote">On Tue, May 19, 2015 at 10:49 AM, Nevin Liber <span dir=3D"ltr" cl=
ass=3D"">&lt;<a href=3D"mailto:nevin@eviloverlord.com" target=3D"_blank" cl=
ass=3D"">nevin@eviloverlord.com</a>&gt;</span> wrote:<br class=3D""><blockq=
uote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc =
solid;padding-left:1ex"><div dir=3D"ltr" class=3D""><div class=3D"gmail_ext=
ra"><div class=3D"gmail_quote"><div class=3D"">Also, consider making unique=
_function(unique_function&amp;&amp;) noexcept.</div></div></div></div></blo=
ckquote><div class=3D""><br class=3D""></div><div class=3D"">+1 for noexcep=
t, and it should be able to avoid calling the move constructor when in remo=
te storage (forcing remote storage if the underlying object has a move cons=
tructor that can throw)</div></div></div></div></div></blockquote><br class=
=3D""></div><div class=3D"">That=E2=80=99s an idea. I don=E2=80=99t know if=
 it=E2=80=99s worth it, but I=E2=80=99ll add it as a note.</div><div class=
=3D""><br class=3D""></div><div class=3D"">The idea would apply to <font fa=
ce=3D"Courier" class=3D"">std::function</font> just as well.</div><div clas=
s=3D""><br class=3D""></div><div class=3D"">The main problem is that most e=
xplicitly-defined move constructors in practice aren=E2=80=99t <font face=
=3D"Courier" class=3D"">noexcept</font>, just because people forget. On the=
 other hand, most classes with an explicitly-defined move constructor (or c=
omposed from something with one) are big enough that the in-wrapper storage=
 optimization won=E2=80=99t apply anyway.</div><div class=3D""><br class=3D=
""></div><div class=3D"">Also, another corner case: the move constructor wi=
ll allocate memory when the source has a non-POCMA (<font face=3D"Courier" =
class=3D"">allocator_traits::propagate_on_container_move_assignment</font>)=
 allocator. I=E2=80=99m not really seeing an exception-safety guarantee bei=
ng feasible.</div></body></html>

<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 />

--Apple-Mail=_9AA3278A-698B-488F-BA75-CF628664B6CA--

.
