220 8322 <68012381-8af4-4d62-a5a4-912c454fba96@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: fmatthew5876@gmail.com
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Proposal: Default swap operation
Date: Tue, 31 Dec 2013 18:05:18 -0800 (PST)
Lines: 196
Approved: news@gmane.org
Message-ID: <68012381-8af4-4d62-a5a4-912c454fba96@isocpp.org>
References: <c505e517-1c73-4486-b9dd-9ec15af1e649@isocpp.org>
 <CAPBZbvxzF1pgzaa=A5KfWDTeX7o0epwWiH5+YES+7u4eX2SG0Q@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; 
	boundary="----=_Part_4695_25600600.1388541918666"
X-Trace: ger.gmane.org 1388541915 28475 80.91.229.3 (1 Jan 2014 02:05:15 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Wed, 1 Jan 2014 02:05:15 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDELF54RTIGRBX7PRWLAKGQERGH7XIA@isocpp.org Wed Jan 01 03:05:23 2014
Return-path: <std-proposals+bncBDELF54RTIGRBX7PRWLAKGQERGH7XIA@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-vc0-f198.google.com ([209.85.220.198])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBDELF54RTIGRBX7PRWLAKGQERGH7XIA@isocpp.org>)
	id 1VyBBR-0003Xx-4K
	for gclcip-std-proposals@m.gmane.org; Wed, 01 Jan 2014 03:05:21 +0100
Original-Received: by mail-vc0-f198.google.com with SMTP id lf12sf14064438vcb.1
        for <gclcip-std-proposals@m.gmane.org>; Tue, 31 Dec 2013 18:05:20 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=date:from:to:message-id:in-reply-to:references:subject:mime-version
         :x-original-sender:reply-to:precedence:mailing-list:list-id
         :list-post:list-help:list-archive:list-subscribe:list-unsubscribe
         :content-type;
        bh=PbnQSUXkGCbSX7drm2zotMQ7Rzv/ZcwnsnKEWk1q4nI=;
        b=eO/twvZ9gZ33F/bYiwxeIc9YDUH9vmM2S/dbrF6PjdHIuDNGpuHp2v3IBsWUbRK0tf
         +LTdIMQ2ubK2D7qIJR81Ef8im5q+BsjkIb5GmsDj1jxHJF/0G5hSdNVrSfgmulUxWk7d
         zBWfVPDq8/edkPSkkj222wKsqEH/9zxlpOBQYHOS6lBXlvKwZKPIOO/f53GmwsalNHiT
         xnGkszxVqpYM1E1gdDkPIR01uHoWsqYvErClpjMQvN+lw1Sm6BNKERyyxS2pmM5ew7nu
         QlQExu0+lklhetfO1JhMJNSPuqgaftKDBWiHV1o11+sdlDFP0FpM/Soc502XVnmUcTNk
         sksw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:date:from:to:message-id:in-reply-to:references
         :subject:mime-version:x-original-sender:reply-to:precedence
         :mailing-list:list-id:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe:content-type;
        bh=PbnQSUXkGCbSX7drm2zotMQ7Rzv/ZcwnsnKEWk1q4nI=;
        b=MWqpcuBD/SzypIIFIE98eRIhZySzVmluFFdBBM1PEKm3RFi9hQ243GU3LTRLfapzdQ
         ANoHrsjTSmyrEqc1EWG34QLNdxoX+gakyDtZvybK6ig3zVr/jypav6TCQSzV5bF9VPWk
         W/vyDXfWZ0GTdmbB9xvOvGbbn7R0hku1/An2/9+yL+4TWU2l63C91jr5OoEG6VKRIUkX
         g68mH54enngs+c+jpswldglHwPnGr1S7mSCMAVcs+BR7OEMFfMeKvq8XeNmek1sQPqMV
         0AkN/FnaO7Xzo/2jqIU4iUHDVeCMj010wb/OEkLboWFFUQvEVapZJmbuTGO8YFlB93EZ
         +pnQ==
X-Gm-Message-State: ALoCoQkXcJvTzkwfDF/Is0Ep3ujqeaC9NOIKQkSx6LiduIuMYF+YJ/A1nsB3diMjs1eiUAFIqU6k
X-Received: by 10.58.181.69 with SMTP id du5mr30568546vec.7.1388541920057;
        Tue, 31 Dec 2013 18:05:20 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.49.48.82 with SMTP id j18ls4053659qen.49.gmail; Tue, 31 Dec
 2013 18:05:19 -0800 (PST)
X-Received: by 10.49.101.73 with SMTP id fe9mr1197qeb.6.1388541919355;
        Tue, 31 Dec 2013 18:05:19 -0800 (PST)
In-Reply-To: <CAPBZbvxzF1pgzaa=A5KfWDTeX7o0epwWiH5+YES+7u4eX2SG0Q@mail.gmail.com>
X-Original-Sender: fmatthew5876@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: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:8322
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/8322>

------=_Part_4695_25600600.1388541918666
Content-Type: text/plain; charset=ISO-8859-1


On Tuesday, December 31, 2013 8:53:46 PM UTC-5, Billy O'Neal wrote:
>
> I don't think this is a good idea -- if a type is going to provide swap, 
> normally it must do so in a non-throwing way. I'd worry that people would 
> just add it in without thinking only to break normal assumptions of what 
> swap does.
>

Maybe, but the defaulted swap calls swap for the members which itself 
should already have the non-throwing rule. If your swap has to do something 
special that might throw, you would have to write it yourself anyway.
 

>
> The other issue here is that "using std::swap" would require including 
> <algorithm>...
>

Implementing swap yourself in this way requires the same.
 

>  
>

> Billy O'Neal
> https://github.com/BillyONeal/ <https://bitbucket.org/BillyONeal/>
> http://stackoverflow.com/users/82320/billy-oneal
> Malware Response Instructor - BleepingComputer.com
>
>
> On Tue, Dec 31, 2013 at 5:42 PM, <fmatth...@gmail.com <javascript:>>wrote:
>
>> Writing swap() is one of those boilerplate kinds of things that is 
>> usually trivial but annoying (and error prone when you change data members 
>> but forget to update swap()).
>>
>> Why not allow this:
>>
>> class Foo {
>>   public:
>>     void swap(Foo& f) = default;
>>   private:
>>     int a;
>>     Bar b;
>>     float c;
>>     Baz* d;
>> };
>>
>> Which would be the equivalent of this:
>>
>> void Foo::swap(Foo& f) {
>>   using std::swap;
>>   swap(a, f.a);
>>   swap(b, f.b);
>>   swap(c, f.c);
>>   swap(d, f.d);
>> }
>>
>> Any reason this wouldn't make it as a proposal?
>>
>> -- 
>>  
>> --- 
>> 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-proposal...@isocpp.org <javascript:>.
>> To post to this group, send email to std-pr...@isocpp.org <javascript:>.
>> Visit this group at 
>> http://groups.google.com/a/isocpp.org/group/std-proposals/.
>>
>
>

-- 

--- 
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/.

------=_Part_4695_25600600.1388541918666
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br>On Tuesday, December 31, 2013 8:53:46 PM UTC-5, Billy =
O'Neal wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-le=
ft: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr">=
I don't think this is a good idea -- if a type is going to provide swap, no=
rmally it must do so in a non-throwing way. I'd worry that people would jus=
t add it in without thinking only to break normal assumptions of what swap =
does.</div></blockquote><div><br></div><div><span style=3D"font-size: 13px;=
">Maybe, but the defaulted swap calls swap for the members which itself sho=
uld already have the non-throwing rule. If your swap has to do something sp=
ecial that might throw, you would have to write it yourself anyway.</span><=
/div><div>&nbsp;</div><blockquote class=3D"gmail_quote" style=3D"margin: 0;=
margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=
=3D"ltr"><div>

<br></div><div>The other issue here is that "using std::swap" would require=
 including &lt;algorithm&gt;...</div></div></blockquote><div><br></div><div=
>Implementing swap yourself in this way requires the same.</div><div>&nbsp;=
</div><blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8=
ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><div><s=
pan style=3D"font-size: 13px;">&nbsp;</span></div></div></blockquote><block=
quote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-le=
ft: 1px #ccc solid;padding-left: 1ex;"><div><br clear=3D"all"><div><div dir=
=3D"ltr"><div>Billy O'Neal</div><div>

<a href=3D"https://bitbucket.org/BillyONeal/" target=3D"_blank" onmousedown=
=3D"this.href=3D'https://www.google.com/url?q\75https%3A%2F%2Fbitbucket.org=
%2FBillyONeal%2F\46sa\75D\46sntz\0751\46usg\75AFQjCNEUaaIry0cea0l0vX6ztWgwQ=
7_4Lg';return true;" onclick=3D"this.href=3D'https://www.google.com/url?q\7=
5https%3A%2F%2Fbitbucket.org%2FBillyONeal%2F\46sa\75D\46sntz\0751\46usg\75A=
FQjCNEUaaIry0cea0l0vX6ztWgwQ7_4Lg';return true;">https://github.com/BillyON=
eal/</a></div><div><a href=3D"http://stackoverflow.com/users/82320/billy-on=
eal" target=3D"_blank" onmousedown=3D"this.href=3D'http://www.google.com/ur=
l?q\75http%3A%2F%2Fstackoverflow.com%2Fusers%2F82320%2Fbilly-oneal\46sa\75D=
\46sntz\0751\46usg\75AFQjCNHY_gA133vyg0yY-U2PNMVA8cCSBg';return true;" oncl=
ick=3D"this.href=3D'http://www.google.com/url?q\75http%3A%2F%2Fstackoverflo=
w.com%2Fusers%2F82320%2Fbilly-oneal\46sa\75D\46sntz\0751\46usg\75AFQjCNHY_g=
A133vyg0yY-U2PNMVA8cCSBg';return true;">http://stackoverflow.com/<wbr>users=
/82320/billy-oneal</a></div>

<div>Malware Response Instructor - BleepingComputer.com</div></div></div>
<br><br><div class=3D"gmail_quote">On Tue, Dec 31, 2013 at 5:42 PM,  <span =
dir=3D"ltr">&lt;<a href=3D"javascript:" target=3D"_blank" gdf-obfuscated-ma=
ilto=3D"sUShiWNYUcMJ" onmousedown=3D"this.href=3D'javascript:';return true;=
" onclick=3D"this.href=3D'javascript:';return true;">fmatth...@gmail.com</a=
>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 =
0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div dir=3D"ltr">Writing swap() is one of those boilerplate kinds of things=
 that is usually trivial but annoying (and error prone when you change data=
 members but forget to update swap()).<div><br></div><div>Why not allow thi=
s:</div>

<div><br></div><div>class Foo {</div><div>&nbsp; public:</div><div>&nbsp; &=
nbsp; void swap(Foo&amp; f) =3D default;</div><div>&nbsp; private:</div><di=
v>&nbsp; &nbsp; int a;</div><div>&nbsp; &nbsp; Bar b;</div><div>&nbsp; &nbs=
p; float c;</div><div>&nbsp; &nbsp; Baz* d;</div><div>};</div>

<div><br></div><div>Which would be the equivalent of this:</div><div><br></=
div><div>void Foo::swap(Foo&amp; f) {<br>&nbsp; using std::swap;</div><div>=
&nbsp; swap(a, f.a);</div><div>&nbsp; swap(b, f.b);</div><div>&nbsp; swap(c=
, f.c);</div><div>

&nbsp; swap(d, f.d);</div><div>}</div><div><br></div><div>Any reason this w=
ouldn't make it as a proposal?</div></div><span><font color=3D"#888888">

<p></p>

-- <br>
&nbsp;<br>
--- <br>
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"=
sUShiWNYUcMJ" onmousedown=3D"this.href=3D'javascript:';return true;" onclic=
k=3D"this.href=3D'javascript:';return true;">std-proposal...@<wbr>isocpp.or=
g</a>.<br>
To post to this group, send email to <a href=3D"javascript:" target=3D"_bla=
nk" gdf-obfuscated-mailto=3D"sUShiWNYUcMJ" onmousedown=3D"this.href=3D'java=
script:';return true;" onclick=3D"this.href=3D'javascript:';return true;">s=
td-pr...@isocpp.org</a>.<br>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank" onmousedown=3D"this.href=3D'http://groups=
..google.com/a/isocpp.org/group/std-proposals/';return true;" onclick=3D"thi=
s.href=3D'http://groups.google.com/a/isocpp.org/group/std-proposals/';retur=
n true;">http://groups.google.com/a/<wbr>isocpp.org/group/std-<wbr>proposal=
s/</a>.<br>
</font></span></blockquote></div><br></div>
</blockquote></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/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_4695_25600600.1388541918666--

.
