220 8321 <CAPBZbvxzF1pgzaa=A5KfWDTeX7o0epwWiH5+YES+7u4eX2SG0Q@mail.gmail.com> article
Path: news.gmane.org!not-for-mail
From: "Billy O'Neal" <billy.oneal@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Proposal: Default swap operation
Date: Tue, 31 Dec 2013 17:53:46 -0800
Lines: 145
Approved: news@gmane.org
Message-ID: <CAPBZbvxzF1pgzaa=A5KfWDTeX7o0epwWiH5+YES+7u4eX2SG0Q@mail.gmail.com>
References: <c505e517-1c73-4486-b9dd-9ec15af1e649@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary=089e0111be76ed4b8304eedef4a3
X-Trace: ger.gmane.org 1388541261 23684 80.91.229.3 (1 Jan 2014 01:54:21 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Wed, 1 Jan 2014 01:54:21 +0000 (UTC)
To: std-proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBDKLBLVE6ADBBUXKRWLAKGQEYWTZ5VY@isocpp.org Wed Jan 01 02:54:29 2014
Return-path: <std-proposals+bncBDKLBLVE6ADBBUXKRWLAKGQEYWTZ5VY@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-pa0-f71.google.com ([209.85.220.71])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBDKLBLVE6ADBBUXKRWLAKGQEYWTZ5VY@isocpp.org>)
	id 1VyB0u-0005Wh-7g
	for gclcip-std-proposals@m.gmane.org; Wed, 01 Jan 2014 02:54:28 +0100
Original-Received: by mail-pa0-f71.google.com with SMTP id kp14sf36795753pab.6
        for <gclcip-std-proposals@m.gmane.org>; Tue, 31 Dec 2013 17:54:27 -0800 (PST)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:mime-version:in-reply-to:references:from:date
         :message-id:subject: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:content-type;
        bh=d1uaFgon2+z1xgEQojPjA+sqAQdnxGOWFymHPAhPLqg=;
        b=YGVCVwQpQ7PBBKmQM1XlCbu7EfUyU6/3UCle+5EfEQ2izOikG0vOZ4bhTqj6RRL3/8
         ITVTN8wpMEU6CDBuXJyHso+uA2LvFtzDuransqsh2EyIy7ADtbi3U4BLodYbhNNNrZHG
         KaTXkOQMOIsKXOOWhItTHvDyjaAqwbPmI7VokChwJvOhqM5rWEWSJD29bbQrgktBsd1l
         mcUlbSAmOjAB+PwxpQ063LX099mkD4GVZsqdhjelwtRRr70U8dZG6tBdyGi77yue7myl
         yWewW99PkD0HRslnTw1H3aUxu/XYSFBgELMWrL2ZgB4UhJDEYcgbHNUSTATuHCpu/m18
         LbUQ==
X-Gm-Message-State: ALoCoQkly/JWEVkHVMNn8vZfMrdY96OyoXP2tM7LmHSGVmDZ7e7BHbv320Zdg9AutDVxlXqSap2n
X-Received: by 10.66.228.67 with SMTP id sg3mr9234600pac.25.1388541267069;
        Tue, 31 Dec 2013 17:54:27 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.49.82.49 with SMTP id f17ls3900574qey.54.gmail; Tue, 31 Dec
 2013 17:54:26 -0800 (PST)
X-Received: by 10.236.105.236 with SMTP id k72mr52406362yhg.30.1388541266489;
        Tue, 31 Dec 2013 17:54:26 -0800 (PST)
Original-Received: from mail-ob0-x22f.google.com (mail-ob0-x22f.google.com [2607:f8b0:4003:c01::22f])
        by mx.google.com with ESMTPS id z21si26854768yhb.74.2013.12.31.17.54.26
        for <std-proposals@isocpp.org>
        (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
        Tue, 31 Dec 2013 17:54:26 -0800 (PST)
Received-SPF: pass (google.com: domain of billy.oneal@gmail.com designates 2607:f8b0:4003:c01::22f as permitted sender) client-ip=2607:f8b0:4003:c01::22f;
Original-Received: by mail-ob0-f175.google.com with SMTP id uz6so13134819obc.6
        for <std-proposals@isocpp.org>; Tue, 31 Dec 2013 17:54:26 -0800 (PST)
X-Received: by 10.182.88.202 with SMTP id bi10mr25188857obb.52.1388541266183;
 Tue, 31 Dec 2013 17:54:26 -0800 (PST)
Original-Received: by 10.182.87.37 with HTTP; Tue, 31 Dec 2013 17:53:46 -0800 (PST)
In-Reply-To: <c505e517-1c73-4486-b9dd-9ec15af1e649@isocpp.org>
X-Original-Sender: billy.oneal@gmail.com
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of billy.oneal@gmail.com designates 2607:f8b0:4003:c01::22f as
 permitted sender) smtp.mail=billy.oneal@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: <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:8321
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/8321>

--089e0111be76ed4b8304eedef4a3
Content-Type: text/plain; charset=ISO-8859-1

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.

The other issue here is that "using std::swap" would require including
<algorithm>...

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, <fmatthew5876@gmail.com> 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-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/.
>

-- 

--- 
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/.

--089e0111be76ed4b8304eedef4a3
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">I don&#39;t think this is a good idea -- if a type is goin=
g to provide swap, normally it must do so in a non-throwing way. I&#39;d wo=
rry that people would just add it in without thinking only to break normal =
assumptions of what swap does.<div>

<br></div><div>The other issue here is that &quot;using std::swap&quot; wou=
ld require including &lt;algorithm&gt;...</div></div><div class=3D"gmail_ex=
tra"><br clear=3D"all"><div><div dir=3D"ltr"><div>Billy O&#39;Neal</div><di=
v>

<a href=3D"https://bitbucket.org/BillyONeal/" target=3D"_blank">https://git=
hub.com/BillyONeal/</a></div><div><a href=3D"http://stackoverflow.com/users=
/82320/billy-oneal" target=3D"_blank">http://stackoverflow.com/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"mailto:fmatthew5876@gmail.com" target=3D"_blank"=
>fmatthew5876@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>=A0 public:</div><div>=A0 =A0 voi=
d swap(Foo&amp; f) =3D default;</div><div>=A0 private:</div><div>=A0 =A0 in=
t a;</div><div>=A0 =A0 Bar b;</div><div>=A0 =A0 float c;</div><div>=A0 =A0 =
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>=A0 using std::swap;</div><div>=A0=
 swap(a, f.a);</div><div>=A0 swap(b, f.b);</div><div>=A0 swap(c, f.c);</div=
><div>

=A0 swap(d, f.d);</div><div>}</div><div><br></div><div>Any reason this woul=
dn&#39;t make it as a proposal?</div></div><span class=3D"HOEnZb"><font col=
or=3D"#888888">

<p></p>

-- <br>
=A0<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%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 at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
</font></span></blockquote></div><br></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 />

--089e0111be76ed4b8304eedef4a3--

.
