Topic: Swapping with volatile lvalues
Author: FrankHB1989 <frankhb1989@gmail.com>
Date: Tue, 21 Jun 2016 00:29:19 -0700 (PDT)
Raw View
------=_Part_4197_932261116.1466494159053
Content-Type: multipart/alternative;
boundary="----=_Part_4198_936751888.1466494159053"
------=_Part_4198_936751888.1466494159053
Content-Type: text/plain; charset=UTF-8
I find swapping between the non-volatile and volatile lvalues may be
useful, e.g. to save/restore errno where it has volatile type. Though it is
easy to roll my own wheels, is it being considered in the standard, e.g.
`template<typename T>void swap(T, volatile&) noexcept`?
--
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/81998cb5-722e-49a1-be98-7ca1e219b72a%40isocpp.org.
------=_Part_4198_936751888.1466494159053
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">I find swapping between the non-volatile and volatile lval=
ues may be useful, e.g. to save/restore errno where it has volatile type. T=
hough it is easy to roll my own wheels, is it being considered in the stand=
ard, e.g. `template<typename T>void swap(T, volatile&) noexcept`?=
<br><br></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;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"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/81998cb5-722e-49a1-be98-7ca1e219b72a%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/81998cb5-722e-49a1-be98-7ca1e219b72a=
%40isocpp.org</a>.<br />
------=_Part_4198_936751888.1466494159053--
------=_Part_4197_932261116.1466494159053--
.
Author: =?UTF-8?Q?Daniel_Kr=C3=BCgler?= <daniel.kruegler@gmail.com>
Date: Tue, 21 Jun 2016 09:49:54 +0200
Raw View
2016-06-21 9:29 GMT+02:00 FrankHB1989 <frankhb1989@gmail.com>:
> I find swapping between the non-volatile and volatile lvalues may be useful,
> e.g. to save/restore errno where it has volatile type. Though it is easy to
> roll my own wheels, is it being considered in the standard, e.g.
> `template<typename T>void swap(T, volatile&) noexcept`?
The way you suggest to provide this (asymmetric) signature, to me that
doesn't seem to be a function that should be named swap and should be
considered during overload resolution of swap functions in the library
as described in [swappable.requirements]. For example, note that
according to the Swappable requirements, there exist a bunch of
requirements regarding symmetry of call expressions and
post-conditions, that don't seem to apply here.
I have not looked deeper into this, but isn't your suggestion more
indicated to be a variant of std::exchange? But even here I'm not 100%
sure that this picture fits.
- 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/CAGNvRgB9K2W%3DAL5y3b7PbVvitDAaTOLXSYzi9rbC2kpZVG%2BZKQ%40mail.gmail.com.
.
Author: FrankHB1989 <frankhb1989@gmail.com>
Date: Tue, 21 Jun 2016 03:12:47 -0700 (PDT)
Raw View
------=_Part_1184_1009700418.1466503967335
Content-Type: multipart/alternative;
boundary="----=_Part_1185_1053112479.1466503967336"
------=_Part_1185_1053112479.1466503967336
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
Call of std::exchange can work, but it seems not so ideal. The return type=
=20
of std::exchange is template parameter type T, so when T is a volatile=20
type, lvalue-to-rvalue conversion would be performed, and there are likely=
=20
more side effects than needed.
I also don't think using the volatile lvalue return value (which is not the=
=20
case for std::exchange) a good idea. Discarded-value expressions can work=
=20
in such cases, but is seems to be strange and too error-prone. So perhaps=
=20
the return type of the call should be void.
Regarding with Swappable requriements and symmetry... how about providing 2=
=20
overloading?
=E5=9C=A8 2016=E5=B9=B46=E6=9C=8821=E6=97=A5=E6=98=9F=E6=9C=9F=E4=BA=8C UTC=
+8=E4=B8=8B=E5=8D=883:49:58=EF=BC=8CDaniel Kr=C3=BCgler=E5=86=99=E9=81=93=
=EF=BC=9A
>
> 2016-06-21 9:29 GMT+02:00 FrankHB1989 <frank...@gmail.com <javascript:>>:=
=20
> > I find swapping between the non-volatile and volatile lvalues may be=20
> useful,=20
> > e.g. to save/restore errno where it has volatile type. Though it is eas=
y=20
> to=20
> > roll my own wheels, is it being considered in the standard, e.g.=20
> > `template<typename T>void swap(T, volatile&) noexcept`?=20
>
> The way you suggest to provide this (asymmetric) signature, to me that=20
> doesn't seem to be a function that should be named swap and should be=20
> considered during overload resolution of swap functions in the library=20
> as described in [swappable.requirements]. For example, note that=20
> according to the Swappable requirements, there exist a bunch of=20
> requirements regarding symmetry of call expressions and=20
> post-conditions, that don't seem to apply here.=20
>
> I have not looked deeper into this, but isn't your suggestion more=20
> indicated to be a variant of std::exchange? But even here I'm not 100%=20
> sure that this picture fits.=20
>
> - Daniel=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.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/9608d5c4-e60f-449e-9078-f27fed1f79fd%40isocpp.or=
g.
------=_Part_1185_1053112479.1466503967336
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Call of std::exchange can work, but it seems not so ideal.=
The return type of std::exchange is template parameter type T, so when T i=
s a volatile type, lvalue-to-rvalue conversion would be performed, and ther=
e are likely more side effects than needed.<br>I also don't think using=
the volatile lvalue return value (which is not=20
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 per=
haps the return type of the call should be void.<br>Regarding with Swappabl=
e requriements and <span class=3D"op_dict3_font24 op_dict3_marginRight">sym=
metry</span>... how about providing 2 overloading?<br><br>=E5=9C=A8 2016=E5=
=B9=B46=E6=9C=8821=E6=97=A5=E6=98=9F=E6=9C=9F=E4=BA=8C UTC+8=E4=B8=8B=E5=8D=
=883:49:58=EF=BC=8CDaniel Kr=C3=BCgler=E5=86=99=E9=81=93=EF=BC=9A<blockquot=
e class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: =
1px #ccc solid;padding-left: 1ex;">2016-06-21 9:29 GMT+02:00 FrankHB1989 &l=
t;<a href=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"UzzHt7=
ojBAAJ" rel=3D"nofollow" onmousedown=3D"this.href=3D'javascript:';r=
eturn true;" onclick=3D"this.href=3D'javascript:';return true;">fra=
nk...@gmail.com</a>>:
<br>> I find swapping between the non-volatile and volatile lvalues may =
be useful,
<br>> e.g. to save/restore errno where it has volatile type. Though it i=
s easy to
<br>> roll my own wheels, is it being considered in the standard, e.g.
<br>> `template<typename T>void swap(T, volatile&) noexcept`?
<br>
<br>The way you suggest to provide this (asymmetric) signature, to me that
<br>doesn't seem to be a function that should be named swap and should =
be
<br>considered during overload resolution of swap functions in the library
<br>as described in [swappable.requirements]. For example, note that
<br>according to the Swappable requirements, there exist a bunch of
<br>requirements regarding symmetry of call expressions and
<br>post-conditions, that don't seem to apply here.
<br>
<br>I have not looked deeper into this, but isn't your suggestion more
<br>indicated to be a variant of std::exchange? But even here I'm not 1=
00%
<br>sure that this picture fits.
<br>
<br>- Daniel
<br></blockquote></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;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"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/9608d5c4-e60f-449e-9078-f27fed1f79fd%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/9608d5c4-e60f-449e-9078-f27fed1f79fd=
%40isocpp.org</a>.<br />
------=_Part_1185_1053112479.1466503967336--
------=_Part_1184_1009700418.1466503967335--
.
Author: =?UTF-8?Q?Daniel_Kr=C3=BCgler?= <daniel.kruegler@gmail.com>
Date: Tue, 21 Jun 2016 12:18:05 +0200
Raw View
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 more
> 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/CAGNvRgCYLywvtFSO65-NKpeycpT4cPnw0SjvQPhE_DRL98UO7g%40mail.gmail.com.
.
Author: Farid Mehrabi <farid.mehrabi@gmail.com>
Date: Tue, 21 Jun 2016 23:06:55 +0430
Raw View
--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:"ar=
ial narrow",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:"arial narrow"=
;,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:"arial narrow",sans-serif=
;font-size:large" dir=3D"ltr"><br></div><div class=3D"gmail_default" style=
=3D"font-family:"arial narrow",sans-serif;font-size:large" dir=3D=
"ltr">regards,</div><div class=3D"gmail_default" style=3D"font-family:"=
;arial narrow",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"><<a hre=
f=3D"mailto:daniel.kruegler@gmail.com" target=3D"_blank">daniel.kruegler@gm=
ail.com</a>></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 <<a href=3D"mailto:frankhb1989@=
gmail.com">frankhb1989@gmail.com</a>>:<br>
> 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=
'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>
> The return type<br>
> of std::exchange is template parameter type T, so when T is a volatile=
type,<br>
> lvalue-to-rvalue conversion would be performed, and there are likely m=
ore<br>
> side effects than needed.<br>
> I also don't think using the volatile lvalue return value (which i=
s not the<br>
> case for std::exchange) a good idea. Discarded-value expressions can w=
ork in<br>
> such cases, but is seems to be strange and too error-prone. So perhaps=
the<br>
> return type of the call should be void.<br>
> Regarding with Swappable requriements and symmetry... how about provid=
ing 2<br>
> 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'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" 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" 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--
.
Author: FrankHB1989 <frankhb1989@gmail.com>
Date: Tue, 21 Jun 2016 16:33:54 -0700 (PDT)
Raw View
------=_Part_104_2136466998.1466552034679
Content-Type: multipart/alternative;
boundary="----=_Part_105_1551560846.1466552034680"
------=_Part_105_1551560846.1466552034680
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
=E5=9C=A8 2016=E5=B9=B46=E6=9C=8822=E6=97=A5=E6=98=9F=E6=9C=9F=E4=B8=89 UTC=
+8=E4=B8=8A=E5=8D=882:37:36=EF=BC=8CFarid Mehrabi=E5=86=99=E9=81=93=EF=BC=
=9A
>
> Whenever I face volatile, the atomic bells start to ring in my ears.=20
> Should swapping a volatile object mean atomic exchange, for non-trivial=
=20
> types we might get in trouble, but for in-built integrals I would rather=
=20
> use std::atomic_exchange.
>
Well, atomic operations are another monsters... Actually I don't want=20
"volatile" as possible.
=20
> Otherwise (if atomicity is not a concern), a cv-cast followed by=20
> conventional swap can do.
>
> I'm afraid you can't. "Reading a volatile object through a non-volatile=
=20
glvalue has undefined behavior." I find no effect way to avoid a volatile=
=20
glvalue referring a volatile object.
=20
> regards,
> FM.
>
> 2016-06-21 14:48 GMT+04:30 Daniel Kr=C3=BCgler <daniel....@gmail.com=20
> <javascript:>>:
>
>> 2016-06-21 12:12 GMT+02:00 FrankHB1989 <frank...@gmail.com <javascript:>
>> >:
>> > 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=
=20
>> type,
>> > lvalue-to-rvalue conversion would be performed, and there are likely=
=20
>> more
>> > side effects than needed.
>> > I also don't think using the volatile lvalue return value (which is no=
t=20
>> the
>> > case for std::exchange) a good idea. Discarded-value expressions can=
=20
>> work in
>> > such cases, but is seems to be strange and too error-prone. So perhaps=
=20
>> the
>> > return type of the call should be void.
>> > Regarding with Swappable requriements and symmetry... how about=20
>> 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 Group=
s=20
>> "ISO C++ Standard - Future Proposals" group.
>> To unsubscribe from this group and stop receiving emails from it, send a=
n=20
>> email to std-proposal...@isocpp.org <javascript:>.
>> To post to this group, send email to std-pr...@isocpp.org <javascript:>.
>> To view this discussion on the web visit=20
>> https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAGNvRgCYLy=
wvtFSO65-NKpeycpT4cPnw0SjvQPhE_DRL98UO7g%40mail.gmail.com
>> .
>>
>
>
>
> --=20
> how am I supposed to end the twisted road of your hair in such a dark=20
> 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/b45ad971-0874-4372-b204-699767d25c21%40isocpp.or=
g.
------=_Part_105_1551560846.1466552034680
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><br>=E5=9C=A8 2016=E5=B9=B46=E6=9C=8822=E6=97=A5=E6=98=
=9F=E6=9C=9F=E4=B8=89 UTC+8=E4=B8=8A=E5=8D=882:37:36=EF=BC=8CFarid Mehrabi=
=E5=86=99=E9=81=93=EF=BC=9A<blockquote class=3D"gmail_quote" style=3D"margi=
n: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><di=
v dir=3D"rtl"><div style=3D"font-family:"arial narrow",sans-serif=
;font-size:large" dir=3D"ltr">Whenever I face volatile, the atomic bells st=
art to ring in my ears. Should swapping a volatile object mean atomic excha=
nge, for non-trivial types we might get in trouble, but for in-built integr=
als I would rather use std::atomic_exchange.</div></div></blockquote><div>W=
ell, atomic operations are another monsters... Actually I don't want &q=
uot;volatile" as possible.<br>=C2=A0<br></div><blockquote class=3D"gma=
il_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid=
;padding-left: 1ex;"><div dir=3D"rtl"><div style=3D"font-family:"arial=
narrow",sans-serif;font-size:large" dir=3D"ltr">Otherwise (if atomici=
ty is not a concern), a cv-cast followed by conventional swap can do.</div>=
<div style=3D"font-family:"arial narrow",sans-serif;font-size:lar=
ge" dir=3D"ltr"><br></div></div></blockquote><div>I'm afraid you can=
9;t. "Reading a volatile object through a non-volatile glvalue has und=
efined behavior." I find no effect way to avoid a volatile glvalue ref=
erring a volatile object.<br><br>=C2=A0<br></div><blockquote class=3D"gmail=
_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;p=
adding-left: 1ex;"><div dir=3D"rtl"><div style=3D"font-family:"arial n=
arrow",sans-serif;font-size:large" dir=3D"ltr"></div><div style=3D"fon=
t-family:"arial narrow",sans-serif;font-size:large" dir=3D"ltr">r=
egards,</div><div style=3D"font-family:"arial narrow",sans-serif;=
font-size:large" dir=3D"ltr">FM.</div></div><div><br><div class=3D"gmail_qu=
ote"><div dir=3D"ltr">2016-06-21 14:48 GMT+04:30 Daniel Kr=C3=BCgler <span =
dir=3D"ltr"><<a href=3D"javascript:" target=3D"_blank" gdf-obfuscated-ma=
ilto=3D"ko2dHxJHBAAJ" rel=3D"nofollow" onmousedown=3D"this.href=3D'java=
script:';return true;" onclick=3D"this.href=3D'javascript:';ret=
urn true;">daniel....@gmail.com</a>></span>:</div><blockquote class=3D"g=
mail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-l=
eft:1ex"><span>2016-06-21 12:12 GMT+02:00 FrankHB1989 <<a href=3D"javasc=
ript:" target=3D"_blank" gdf-obfuscated-mailto=3D"ko2dHxJHBAAJ" rel=3D"nofo=
llow" onmousedown=3D"this.href=3D'javascript:';return true;" onclic=
k=3D"this.href=3D'javascript:';return true;">frank...@gmail.com</a>=
>:<br>
> 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=
'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><br>
> The return type<br>
> of std::exchange is template parameter type T, so when T is a volatile=
type,<br>
> lvalue-to-rvalue conversion would be performed, and there are likely m=
ore<br>
> side effects than needed.<br>
> I also don't think using the volatile lvalue return value (which i=
s not the<br>
> case for std::exchange) a good idea. Discarded-value expressions can w=
ork in<br>
> such cases, but is seems to be strange and too error-prone. So perhaps=
the<br>
> return type of the call should be void.<br>
> Regarding with Swappable requriements and symmetry... how about provid=
ing 2<br>
> 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't thought carefully through it.<br>
<span><br>
- Daniel<br>
<br>
--<br>
You received this message because you are subscribed to the Google Groups &=
quot;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"=
ko2dHxJHBAAJ" rel=3D"nofollow" onmousedown=3D"this.href=3D'javascript:&=
#39;;return true;" onclick=3D"this.href=3D'javascript:';return true=
;">std-proposal...@<wbr>isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"javascript:" target=3D"_bla=
nk" gdf-obfuscated-mailto=3D"ko2dHxJHBAAJ" rel=3D"nofollow" onmousedown=3D"=
this.href=3D'javascript:';return true;" onclick=3D"this.href=3D'=
;javascript:';return true;">std-pr...@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"nofollow" target=3D"_blank" =
onmousedown=3D"this.href=3D'https://groups.google.com/a/isocpp.org/d/ms=
gid/std-proposals/CAGNvRgCYLywvtFSO65-NKpeycpT4cPnw0SjvQPhE_DRL98UO7g%40mai=
l.gmail.com';return true;" onclick=3D"this.href=3D'https://groups.g=
oogle.com/a/isocpp.org/d/msgid/std-proposals/CAGNvRgCYLywvtFSO65-NKpeycpT4c=
Pnw0SjvQPhE_DRL98UO7g%40mail.gmail.com';return true;">https://groups.go=
ogle.com/a/<wbr>isocpp.org/d/msgid/std-<wbr>proposals/CAGNvRgCYLywvtFSO65-<=
wbr>NKpeycpT4cPnw0SjvQPhE_<wbr>DRL98UO7g%40mail.gmail.com</a>.<br>
</blockquote></div><br><br clear=3D"all"><div><br></div>-- <br><div><div di=
r=3D"rtl"><div><div dir=3D"ltr">how am I supposed to end the twisted road o=
f=C2=A0 your hair in such a dark night??<br>unless the candle of your face =
does shed some light upon my way!!!<br></div></div></div></div>
</div>
</blockquote></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;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"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/b45ad971-0874-4372-b204-699767d25c21%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/b45ad971-0874-4372-b204-699767d25c21=
%40isocpp.org</a>.<br />
------=_Part_105_1551560846.1466552034680--
------=_Part_104_2136466998.1466552034679--
.