220 26367 <CALDL7dFth8B=XvDL4pAb_jy=QAKJ_J6VWs-8vMxnmsOxz=R-DA@mail.gmail.com> article
Path: news.gmane.org!not-for-mail
From: Farid Mehrabi <farid.mehrabi@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Swapping with volatile lvalues
Date: Tue, 21 Jun 2016 23:06:55 +0430
Lines: 171
Approved: news@gmane.org
Message-ID: <CALDL7dFth8B=XvDL4pAb_jy=QAKJ_J6VWs-8vMxnmsOxz=R-DA@mail.gmail.com>
References: <81998cb5-722e-49a1-be98-7ca1e219b72a@isocpp.org>
 <CAGNvRgB9K2W=AL5y3b7PbVvitDAaTOLXSYzi9rbC2kpZVG+ZKQ@mail.gmail.com>
 <9608d5c4-e60f-449e-9078-f27fed1f79fd@isocpp.org> <CAGNvRgCYLywvtFSO65-NKpeycpT4cPnw0SjvQPhE_DRL98UO7g@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary=94eb2c06c64250b9b30535ce1db5
X-Trace: ger.gmane.org 1466534260 15125 80.91.229.3 (21 Jun 2016 18:37:40 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Tue, 21 Jun 2016 18:37:40 +0000 (UTC)
To: std-proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBC27JR6ERAOBB34SU25QKGQE7QKUQIY@isocpp.org Tue Jun 21 20:37:39 2016
Return-path: <std-proposals+bncBC27JR6ERAOBB34SU25QKGQE7QKUQIY@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-lf0-f70.google.com ([209.85.215.70])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBC27JR6ERAOBB34SU25QKGQE7QKUQIY@isocpp.org>)
	id 1bFQYK-0008TB-MF
	for gclcip-std-proposals@m.gmane.org; Tue, 21 Jun 2016 20:37:36 +0200
Original-Received: by mail-lf0-f70.google.com with SMTP id a2sf19536377lfe.0
        for <gclcip-std-proposals@m.gmane.org>; Tue, 21 Jun 2016 11:37:36 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=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:x-spam-checked-in-group:list-post
         :list-help:list-archive:list-subscribe:list-unsubscribe;
        bh=4l9fQ0N53L3JY+GXZjJGJLwRhBOwuly694FVvKwxsOM=;
        b=lH9bta7668pMOLwHxPiv7Js07to8f00pBIJfYn718pR1S3EXKERigccMfwmJBAhjYe
         7s/IicDloPp+Uqog9ApOSYkxVpd1cqPxjHg3bz2x48xQFT5zCS9ug3oyKZKbfID0hFLD
         m6O5NPNVYZo2HR19RlIPwpqmi0zIxBWMGTEgNmUNfL4lEwmyUmnRAV6ipN/SOGM5MEVx
         xgLlFpzRphoS7EnmrnZBA29QGFA851PX75bw8Wf6UY07TI3TQBITdkxJrwsE/7zns51S
         KB+v4Vzv7dI9iKAkAq9hcfqsoR92ZdBjjPuCZML0Nw9jmaYQZm9QhxhBDpHrfFYd5M0G
         ms3w==
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:x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=4l9fQ0N53L3JY+GXZjJGJLwRhBOwuly694FVvKwxsOM=;
        b=UPKB6UqzGL1op6jQEsIOYE4okMGVXjcWgIW84VsgOsdNAqXwfiqH6ontQ4FwVIIucM
         s9KNoYA8r/PuqUqbCsdiyvm5NzNJZFUYWhOYqMmgd4Q/ICWq7uPcuVAlstsaHrGD6inh
         cdDRpgWzk2Q/GLCZi0MfEo3CflbZkw2jXAxgz30kPdzOEfhScHNxdD3jxscBoNKCm3Fa
         UjNhSc7IDdowxawyc9s1M8GJqbtj4v3j7Qdd23KnhacgtgBidf+rgXSo2WIsm84XEVOU
         Fg/Oh4+CxAt/bvoJthNamBojQ8VeDLzDzgjdRI8G6eVQEvzq4Q8GEtFOOADWQMNaLrje
         00ng==
X-Gm-Message-State: ALyK8tK7KpPvvG/dxYS4fVJMPv/E1kwavwDffDNaRhqBS/gGQasgQN/cT6zmcinvTu9lTw==
X-Received: by 10.157.42.106 with SMTP id t97mr24896564ota.0.1466534256028;
        Tue, 21 Jun 2016 11:37:36 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.157.18.181 with SMTP id g50ls3984513otg.36.gmail; Tue, 21 Jun
 2016 11:37:35 -0700 (PDT)
X-Received: by 10.200.42.43 with SMTP id k40mr30894279qtk.98.1466534255092;
        Tue, 21 Jun 2016 11:37:35 -0700 (PDT)
Original-Received: from mail-qk0-x229.google.com (mail-qk0-x229.google.com. [2607:f8b0:400d:c09::229])
        by mx.google.com with ESMTPS id v65si1037569qkh.228.2016.06.21.11.37.35
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Tue, 21 Jun 2016 11:37:35 -0700 (PDT)
Received-SPF: pass (google.com: domain of farid.mehrabi@gmail.com designates 2607:f8b0:400d:c09::229 as permitted sender) client-ip=2607:f8b0:400d:c09::229;
Original-Received: by mail-qk0-x229.google.com with SMTP id t127so33610524qkf.1
        for <std-proposals@isocpp.org>; Tue, 21 Jun 2016 11:37:35 -0700 (PDT)
X-Received: by 10.55.181.1 with SMTP id e1mr28937791qkf.99.1466534254916; Tue,
 21 Jun 2016 11:37:34 -0700 (PDT)
Original-Received: by 10.55.141.131 with HTTP; Tue, 21 Jun 2016 11:36:55 -0700 (PDT)
In-Reply-To: <CAGNvRgCYLywvtFSO65-NKpeycpT4cPnw0SjvQPhE_DRL98UO7g@mail.gmail.com>
X-Original-Sender: farid.mehrabi@gmail.com
X-Original-Authentication-Results: mx.google.com;       dkim=pass
 header.i=@gmail.com;       spf=pass (google.com: domain of
 farid.mehrabi@gmail.com designates 2607:f8b0:400d:c09::229 as permitted
 sender) smtp.mailfrom=farid.mehrabi@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-Spam-Checked-In-Group: std-proposals@isocpp.org
X-Google-Group-Id: 399137483710
List-Post: <https://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <https://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <https://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <https://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>,
 <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:26367
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/26367>

--94eb2c06c64250b9b30535ce1db5
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Whenever I face volatile, the atomic bells start to ring in my ears. Should
swapping a volatile object mean atomic exchange, for non-trivial types we
might get in trouble, but for in-built integrals I would rather use
std::atomic_exchange.
Otherwise (if atomicity is not a concern), a cv-cast followed by
conventional swap can do.

regards,
FM.

2016-06-21 14:48 GMT+04:30 Daniel Kr=C3=BCgler <daniel.kruegler@gmail.com>:

> 2016-06-21 12:12 GMT+02:00 FrankHB1989 <frankhb1989@gmail.com>:
> > Call of std::exchange can work, but it seems not so ideal.
>
> This is a misunderstanding of my possibly ambiguous response. I didn't
> mean to use std::exchange, but instead I was trying to suggest that if
> you were considering to reuse an existing name it should better be
> exchange instead of swap.
>
> > The return type
> > of std::exchange is template parameter type T, so when T is a volatile
> type,
> > lvalue-to-rvalue conversion would be performed, and there are likely mo=
re
> > side effects than needed.
> > I also don't think using the volatile lvalue return value (which is not
> the
> > case for std::exchange) a good idea. Discarded-value expressions can
> work in
> > such cases, but is seems to be strange and too error-prone. So perhaps
> the
> > return type of the call should be void.
> > Regarding with Swappable requriements and symmetry... how about
> providing 2
> > overloading?
>
> I still feel uneasy about it, especially when trying to make a
> consistent sense with your suggested overloads (even assuming that
> both overloads would be provided) and the Swappable post-conditions.
> But again, I haven't thought carefully through it.
>
> - Daniel
>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAGNvRgCYLyw=
vtFSO65-NKpeycpT4cPnw0SjvQPhE_DRL98UO7g%40mail.gmail.com
> .
>



--=20
how am I supposed to end the twisted road of  your hair in such a dark
night??
unless the candle of your face does shed some light upon my way!!!

--=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.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/CALDL7dFth8B%3DXvDL4pAb_jy%3DQAKJ_J6VWs-8vMxnmsO=
xz%3DR-DA%40mail.gmail.com.

--94eb2c06c64250b9b30535ce1db5
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"rtl"><div class=3D"gmail_default" style=3D"font-family:&quot;ar=
ial narrow&quot;,sans-serif;font-size:large" dir=3D"ltr">Whenever I face vo=
latile, the atomic bells start to ring in my ears. Should swapping a volati=
le object mean atomic exchange, for non-trivial types we might get in troub=
le, but for in-built integrals I would rather use std::atomic_exchange.</di=
v><div class=3D"gmail_default" style=3D"font-family:&quot;arial narrow&quot=
;,sans-serif;font-size:large" dir=3D"ltr">Otherwise (if atomicity is not a =
concern), a cv-cast followed by conventional swap can do.</div><div class=
=3D"gmail_default" style=3D"font-family:&quot;arial narrow&quot;,sans-serif=
;font-size:large" dir=3D"ltr"><br></div><div class=3D"gmail_default" style=
=3D"font-family:&quot;arial narrow&quot;,sans-serif;font-size:large" dir=3D=
"ltr">regards,</div><div class=3D"gmail_default" style=3D"font-family:&quot=
;arial narrow&quot;,sans-serif;font-size:large" dir=3D"ltr">FM.</div></div>=
<div class=3D"gmail_extra"><br><div class=3D"gmail_quote"><div dir=3D"ltr">=
2016-06-21 14:48 GMT+04:30 Daniel Kr=C3=BCgler <span dir=3D"ltr">&lt;<a hre=
f=3D"mailto:daniel.kruegler@gmail.com" target=3D"_blank">daniel.kruegler@gm=
ail.com</a>&gt;</span>:</div><blockquote class=3D"gmail_quote" style=3D"mar=
gin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=3D"=
">2016-06-21 12:12 GMT+02:00 FrankHB1989 &lt;<a href=3D"mailto:frankhb1989@=
gmail.com">frankhb1989@gmail.com</a>&gt;:<br>
&gt; Call of std::exchange can work, but it seems not so ideal.<br>
<br>
</span>This is a misunderstanding of my possibly ambiguous response. I didn=
&#39;t<br>
mean to use std::exchange, but instead I was trying to suggest that if<br>
you were considering to reuse an existing name it should better be<br>
exchange instead of swap.<br>
<span class=3D""><br>
&gt; The return type<br>
&gt; of std::exchange is template parameter type T, so when T is a volatile=
 type,<br>
&gt; lvalue-to-rvalue conversion would be performed, and there are likely m=
ore<br>
&gt; side effects than needed.<br>
&gt; I also don&#39;t think using the volatile lvalue return value (which i=
s not the<br>
&gt; case for std::exchange) a good idea. Discarded-value expressions can w=
ork in<br>
&gt; such cases, but is seems to be strange and too error-prone. So perhaps=
 the<br>
&gt; return type of the call should be void.<br>
&gt; Regarding with Swappable requriements and symmetry... how about provid=
ing 2<br>
&gt; overloading?<br>
<br>
</span>I still feel uneasy about it, especially when trying to make a<br>
consistent sense with your suggested overloads (even assuming that<br>
both overloads would be provided) and the Swappable post-conditions.<br>
But again, I haven&#39;t thought carefully through it.<br>
<span class=3D""><br>
- Daniel<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%2Bunsubscribe@isocpp.org">std-propo=
sals+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>
</span>To view this discussion on the web visit <a href=3D"https://groups.g=
oogle.com/a/isocpp.org/d/msgid/std-proposals/CAGNvRgCYLywvtFSO65-NKpeycpT4c=
Pnw0SjvQPhE_DRL98UO7g%40mail.gmail.com" rel=3D"noreferrer" target=3D"_blank=
">https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAGNvRgCYLyw=
vtFSO65-NKpeycpT4cPnw0SjvQPhE_DRL98UO7g%40mail.gmail.com</a>.<br>
</blockquote></div><br><br clear=3D"all"><div><br></div>-- <br><div class=
=3D"gmail_signature" data-smartmail=3D"gmail_signature"><div dir=3D"rtl"><d=
iv><div dir=3D"ltr">how am I supposed to end the twisted road of=C2=A0 your=
 hair in such a dark night??<br>unless the candle of your face does shed so=
me light upon my way!!!<br></div></div></div></div>
</div>

<p></p>

-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CALDL7dFth8B%3DXvDL4pAb_jy%3DQAKJ_J6V=
Ws-8vMxnmsOxz%3DR-DA%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfoote=
r">https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CALDL7dFth8=
B%3DXvDL4pAb_jy%3DQAKJ_J6VWs-8vMxnmsOxz%3DR-DA%40mail.gmail.com</a>.<br />

--94eb2c06c64250b9b30535ce1db5--

.
