Topic: operator void()
Author: florian.csdt@gmail.com
Date: Tue, 7 Mar 2017 07:56:58 -0800 (PST)
Raw View
------=_Part_910_842561265.1488902218665
Content-Type: multipart/alternative;
boundary="----=_Part_911_163860534.1488902218665"
------=_Part_911_163860534.1488902218665
Content-Type: text/plain; charset=UTF-8
For now, operator void() is allowed but never used (unless explicitly
called with obj.operator void() ).
I propose to add a meaning to this conversion operator: it is called when
ever the result of an expression isn't used.
First, this is not the same as calling the destructor on a temporary object.
This would allow to call a specific function with that kind of syntax:
myobj;
myobj.mymember;
Basically, if the result of an expression is not used, it calls the (
*implicit*) operator void().
If you write (void) myobj or static_cast<void>(myobj), it calls the
explicit operator void().
If you write reinterpret_cast<void>(myobj), nothing happens: *no* operator
void() is called.
If the operator void() should be called but doesn't exist, nothing happens:
*no* operator void() is called.
If the operator void() should be called but is deleted: the program is
ill-formed.
If a function parameter is not used within the function body, nothing
happens: *no* operator void() is called.
I'm not sure what kind of uses this can have, but this would add a meaning
to something that is already syntactically valid (you already can write operator
void() ), and some languages allow to call a function without parenthesis.
I'm pretty sure some people already have some use cases for this kind of
features like static analysis of the code.
The pitfall I can see with this are the following:
- With the previous rules, myobj = expr; would call the operator void()
because the operator=() returns a reference to the object which is not
used.
A solution to this could be to not return a reference to the object after
an affectation (this breaks the affectation chaining) or return a wrapper
to the reference (add boilerplate).
--
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/3cb45c49-fc41-4922-b35c-49871dd00a54%40isocpp.org.
------=_Part_911_163860534.1488902218665
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">For now, <span style=3D"background-color: rgb(238, 238, 23=
8);"><span style=3D"font-family: courier new,monospace;">operator void()</s=
pan></span> is allowed but never used (unless explicitly called with <span =
style=3D"background-color: rgb(238, 238, 238);"><span style=3D"font-family:=
courier new,monospace;">obj.operator void()</span></span> ).<br>I propose =
to add a meaning to this conversion operator: it is called when ever the re=
sult of an expression isn't used.<br>First, this is not the same as cal=
ling the destructor on a temporary object.<br><br>This would allow to call =
a specific function with that kind of syntax:<br><div class=3D"prettyprint"=
style=3D"background-color: rgb(250, 250, 250); border-color: rgb(187, 187,=
187); border-style: solid; border-width: 1px; word-wrap: break-word;"><cod=
e class=3D"prettyprint"><div class=3D"subprettyprint"><div class=3D"prettyp=
rint" style=3D"background-color: rgb(250, 250, 250); border-color: rgb(187,=
187, 187); border-style: solid; border-width: 1px; word-wrap: break-word;"=
><code class=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify">myobj;<br>myobj</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">.</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify">mymember</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">;<br></span></div></code></div><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify"></span></div></code></div=
><br>Basically, if the result of an expression is not used, it calls the (<=
i>implicit</i>) <span style=3D"font-family: times new roman,serif;"><span s=
tyle=3D"background-color: rgb(238, 238, 238);"><span style=3D"font-family: =
courier new,monospace;">operator void()</span></span></span><span style=3D"=
font-family: times new roman,serif;"><span style=3D"background-color: rgb(2=
38, 238, 238);"><span style=3D"font-family: courier new,monospace;"></span>=
</span></span>.<br>If you write <span style=3D"font-family: courier new,mon=
ospace;"><span style=3D"background-color: rgb(238, 238, 238);">(void) myobj=
</span></span> or <span style=3D"font-family: courier new,monospace;"><span=
style=3D"background-color: rgb(238, 238, 238);">static_cast<void>(my=
obj)</span></span>, it calls the explicit <span style=3D"font-family: couri=
er new,monospace;"><span style=3D"background-color: rgb(238, 238, 238);">op=
erator void()</span></span>.<br>If you write <span style=3D"background-colo=
r: rgb(238, 238, 238);"><span style=3D"font-family: courier new,monospace;"=
>reinterpret_cast<void>(myobj)</span></span>, nothing happens: <b>no<=
/b> <span style=3D"font-family: courier new,monospace;"><span style=3D"back=
ground-color: rgb(238, 238, 238);">operator void()</span></span> is called.=
<br>If the <span style=3D"background-color: rgb(238, 238, 238);"><span styl=
e=3D"font-family: courier new,monospace;">operator void()</span></span> sho=
uld be called but doesn't exist, nothing happens: <b>no</b> <span style=
=3D"font-family: courier new,monospace;"><span style=3D"background-color: r=
gb(238, 238, 238);">operator void()</span></span> is called.<br>If the <spa=
n style=3D"background-color: rgb(238, 238, 238);"><span style=3D"font-famil=
y: courier new,monospace;">operator void()</span></span> should be called b=
ut is <span style=3D"background-color: rgb(238, 238, 238);"><span style=3D"=
font-family: courier new,monospace;">delete</span></span>d: the program is =
ill-formed.<br>If a function parameter is not used within the function body=
, nothing happens: <b>no</b> <span style=3D"font-family: courier new,monosp=
ace;"><span style=3D"background-color: rgb(238, 238, 238);">operator void()=
</span></span> is called.<br><br>I'm not sure what kind of uses this ca=
n have, but this would add a meaning to something that is already syntactic=
ally valid (you already can write <span style=3D"font-family: courier new,m=
onospace;"><span style=3D"background-color: rgb(238, 238, 238);">operator v=
oid()</span></span> ), and some languages allow to call a function without =
parenthesis.<br>I'm pretty sure some people already have some use cases=
for this kind of features like static analysis of the code.<br><br>The pit=
fall I can see with this are the following:<br><ul><li>With the previous ru=
les, <span style=3D"font-family: courier new,monospace;"><span style=3D"bac=
kground-color: rgb(238, 238, 238);">myobj =3D expr;</span></span> would cal=
l the <span style=3D"background-color: rgb(238, 238, 238);"><span style=3D"=
font-family: courier new,monospace;">operator void()</span></span> because =
the <span style=3D"background-color: rgb(238, 238, 238);"><span style=3D"fo=
nt-family: courier new,monospace;">operator=3D()</span></span> returns a re=
ference to the object which is not used.</li></ul>A solution to this could =
be to not return a reference to the object after an affectation (this break=
s the affectation chaining) or return a wrapper to the reference (add boile=
rplate).<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/3cb45c49-fc41-4922-b35c-49871dd00a54%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/3cb45c49-fc41-4922-b35c-49871dd00a54=
%40isocpp.org</a>.<br />
------=_Part_911_163860534.1488902218665--
------=_Part_910_842561265.1488902218665--
.
Author: Brittany Friedman <fourthgeek@gmail.com>
Date: Tue, 7 Mar 2017 10:05:29 -0600
Raw View
--001a1149ad76535ae2054a262e80
Content-Type: text/plain; charset=UTF-8
On Tue, Mar 7, 2017 at 9:56 AM, <florian.csdt@gmail.com> wrote:
> For now, operator void() is allowed but never used (unless explicitly
> called with obj.operator void() ).
> I propose to add a meaning to this conversion operator: it is called when
> ever the result of an expression isn't used.
> First, this is not the same as calling the destructor on a temporary
> object.
>
> This would allow to call a specific function with that kind of syntax:
> myobj;
> myobj.mymember;
>
> Basically, if the result of an expression is not used, it calls the (
> *implicit*) operator void().
> If you write (void) myobj or static_cast<void>(myobj), it calls the
> explicit operator void().
> If you write reinterpret_cast<void>(myobj), nothing happens: *no* operator
> void() is called.
> If the operator void() should be called but doesn't exist, nothing
> happens: *no* operator void() is called.
> If the operator void() should be called but is deleted: the program is
> ill-formed.
> If a function parameter is not used within the function body, nothing
> happens: *no* operator void() is called.
>
> I'm not sure what kind of uses this can have, but this would add a meaning
> to something that is already syntactically valid (you already can write operator
> void() ), and some languages allow to call a function without parenthesis.
> I'm pretty sure some people already have some use cases for this kind of
> features like static analysis of the code.
>
> The pitfall I can see with this are the following:
>
> - With the previous rules, myobj = expr; would call the operator void()
> because the operator=() returns a reference to the object which is not
> used.
>
> A solution to this could be to not return a reference to the object after
> an affectation (this breaks the affectation chaining) or return a wrapper
> to the reference (add boilerplate).
>
> --
> 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/3cb45c49-fc41-4922-
> b35c-49871dd00a54%40isocpp.org
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/3cb45c49-fc41-4922-b35c-49871dd00a54%40isocpp.org?utm_medium=email&utm_source=footer>
> .
>
If you don't even have one practical example of how this would be useful
then I don't know why you would expect the committee to spend time
considering it.
Other proposals, like "regular void", could make use of operator void in
ways that conflict with your idea.
--
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/CADbh%2BeRk66Jx7JtDZ7Fa7haj3%3DMGOaojQWCwikm4%2BOcXrQQOCA%40mail.gmail.com.
--001a1149ad76535ae2054a262e80
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote">On T=
ue, Mar 7, 2017 at 9:56 AM, <span dir=3D"ltr"><<a href=3D"mailto:floria=
n.csdt@gmail.com" target=3D"_blank">florian.csdt@gmail.com</a>></span> w=
rote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8e=
x;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir=3D"ltr"=
>For now, <span style=3D"background-color:rgb(238,238,238)"><span style=3D"=
font-family:"courier new",monospace">operator void()</span></span=
> is allowed but never used (unless explicitly called with <span style=3D"b=
ackground-color:rgb(238,238,238)"><span style=3D"font-family:"courier =
new",monospace">obj.operator void()</span></span> ).<br>I propose to a=
dd a meaning to this conversion operator: it is called when ever the result=
of an expression isn't used.<br>First, this is not the same as calling=
the destructor on a temporary object.<br><br>This would allow to call a sp=
ecific function with that kind of syntax:<br><div class=3D"gmail-m_14867118=
47369847919prettyprint" style=3D"background-color:rgb(250,250,250);border-c=
olor:rgb(187,187,187);border-style:solid;border-width:1px;word-wrap:break-w=
ord"><code class=3D"gmail-m_1486711847369847919prettyprint"><div class=3D"g=
mail-m_1486711847369847919subprettyprint"><div class=3D"gmail-m_14867118473=
69847919prettyprint" style=3D"background-color:rgb(250,250,250);border-colo=
r:rgb(187,187,187);border-style:solid;border-width:1px;word-wrap:break-word=
"><code class=3D"gmail-m_1486711847369847919prettyprint"><div class=3D"gmai=
l-m_1486711847369847919subprettyprint"><span style=3D"color:rgb(0,0,0)" cla=
ss=3D"gmail-m_1486711847369847919styled-by-prettify">myobj;<br>myobj</span>=
<span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_1486711847369847919st=
yled-by-prettify">.</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m=
_1486711847369847919styled-by-prettify">mymember</span><span style=3D"color=
:rgb(102,102,0)" class=3D"gmail-m_1486711847369847919styled-by-prettify">;<=
br></span></div></code></div><span style=3D"color:rgb(102,102,0)" class=3D"=
gmail-m_1486711847369847919styled-by-prettify"></span></div></code></div><b=
r>Basically, if the result of an expression is not used, it calls the (<i>i=
mplicit</i>) <span style=3D"font-family:"times new roman",serif">=
<span style=3D"background-color:rgb(238,238,238)"><span style=3D"font-famil=
y:"courier new",monospace">operator void()</span></span></span><s=
pan style=3D"font-family:"times new roman",serif"><span style=3D"=
background-color:rgb(238,238,238)"><span style=3D"font-family:"courier=
new",monospace"></span></span></span>.<br>If you write <span style=3D=
"font-family:"courier new",monospace"><span style=3D"background-c=
olor:rgb(238,238,238)">(void) myobj</span></span> or <span style=3D"font-fa=
mily:"courier new",monospace"><span style=3D"background-color:rgb=
(238,238,238)">static_cast<void>(myobj)</span></span>, it calls the e=
xplicit <span style=3D"font-family:"courier new",monospace"><span=
style=3D"background-color:rgb(238,238,238)">operator void()</span></span>.=
<br>If you write <span style=3D"background-color:rgb(238,238,238)"><span st=
yle=3D"font-family:"courier new",monospace">reinterpret_cast<v=
oid>(myobj)</span></span>, nothing happens: <b>no</b> <span style=3D"fon=
t-family:"courier new",monospace"><span style=3D"background-color=
:rgb(238,238,238)">operator void()</span></span> is called.<br>If the <span=
style=3D"background-color:rgb(238,238,238)"><span style=3D"font-family:&qu=
ot;courier new",monospace">operator void()</span></span> should be cal=
led but doesn't exist, nothing happens: <b>no</b> <span style=3D"font-f=
amily:"courier new",monospace"><span style=3D"background-color:rg=
b(238,238,238)">operator void()</span></span> is called.<br>If the <span st=
yle=3D"background-color:rgb(238,238,238)"><span style=3D"font-family:"=
courier new",monospace">operator void()</span></span> should be called=
but is <span style=3D"background-color:rgb(238,238,238)"><span style=3D"fo=
nt-family:"courier new",monospace">delete</span></span>d: the pro=
gram is ill-formed.<br>If a function parameter is not used within the funct=
ion body, nothing happens: <b>no</b> <span style=3D"font-family:"couri=
er new",monospace"><span style=3D"background-color:rgb(238,238,238)">o=
perator void()</span></span> is called.<br><br>I'm not sure what kind o=
f uses this can have, but this would add a meaning to something that is alr=
eady syntactically valid (you already can write <span style=3D"font-family:=
"courier new",monospace"><span style=3D"background-color:rgb(238,=
238,238)">operator void()</span></span> ), and some languages allow to call=
a function without parenthesis.<br>I'm pretty sure some people already=
have some use cases for this kind of features like static analysis of the =
code.<br><br>The pitfall I can see with this are the following:<br><ul><li>=
With the previous rules, <span style=3D"font-family:"courier new"=
,monospace"><span style=3D"background-color:rgb(238,238,238)">myobj =3D exp=
r;</span></span> would call the <span style=3D"background-color:rgb(238,238=
,238)"><span style=3D"font-family:"courier new",monospace">operat=
or void()</span></span> because the <span style=3D"background-color:rgb(238=
,238,238)"><span style=3D"font-family:"courier new",monospace">op=
erator=3D()</span></span> returns a reference to the object which is not us=
ed.</li></ul>A solution to this could be to not return a reference to the o=
bject after an affectation (this breaks the affectation chaining) or return=
a wrapper to the reference (add boilerplate).<span class=3D"gmail-HOEnZb">=
<font color=3D"#888888"><br></font></span></div><span class=3D"gmail-HOEnZb=
"><font color=3D"#888888">
<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" target=3D"_=
blank">std-proposals+unsubscribe@<wbr>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>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/3cb45c49-fc41-4922-b35c-49871dd00a54%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter" target=3D"_blank">=
https://groups.google.com/a/<wbr>isocpp.org/d/msgid/std-<wbr>proposals/3cb4=
5c49-fc41-4922-<wbr>b35c-49871dd00a54%40isocpp.org</a><wbr>.<br></font></sp=
an></blockquote><div><br></div><div>If you don't even have one practica=
l example of how this would be useful then I don't know why you would e=
xpect the committee to spend time considering it.</div><div><br></div><div>=
Other proposals, like "regular void", could make use of operator =
void in ways that conflict with your idea.</div></div><br></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/CADbh%2BeRk66Jx7JtDZ7Fa7haj3%3DMGOaoj=
QWCwikm4%2BOcXrQQOCA%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfoote=
r">https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CADbh%2BeRk=
66Jx7JtDZ7Fa7haj3%3DMGOaojQWCwikm4%2BOcXrQQOCA%40mail.gmail.com</a>.<br />
--001a1149ad76535ae2054a262e80--
.
Author: florian.csdt@gmail.com
Date: Tue, 7 Mar 2017 08:15:21 -0800 (PST)
Raw View
------=_Part_569_450392758.1488903321794
Content-Type: multipart/alternative;
boundary="----=_Part_570_354768455.1488903321795"
------=_Part_570_354768455.1488903321795
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
Le mardi 7 mars 2017 17:05:31 UTC+1, Brittany Friedman a =C3=A9crit :
>
> On Tue, Mar 7, 2017 at 9:56 AM, <floria...@gmail.com <javascript:>> wrote=
:
>
>> For now, operator void() is allowed but never used (unless explicitly=20
>> called with obj.operator void() ).
>> I propose to add a meaning to this conversion operator: it is called whe=
n=20
>> ever the result of an expression isn't used.
>> First, this is not the same as calling the destructor on a temporary=20
>> object.
>>
>> This would allow to call a specific function with that kind of syntax:
>> myobj;
>> myobj.mymember;
>>
>> Basically, if the result of an expression is not used, it calls the (
>> *implicit*) operator void().
>> If you write (void) myobj or static_cast<void>(myobj), it calls the=20
>> explicit operator void().
>> If you write reinterpret_cast<void>(myobj), nothing happens: *no* operat=
or=20
>> void() is called.
>> If the operator void() should be called but doesn't exist, nothing=20
>> happens: *no* operator void() is called.
>> If the operator void() should be called but is deleted: the program is=
=20
>> ill-formed.
>> If a function parameter is not used within the function body, nothing=20
>> happens: *no* operator void() is called.
>>
>> I'm not sure what kind of uses this can have, but this would add a=20
>> meaning to something that is already syntactically valid (you already ca=
n=20
>> write operator void() ), and some languages allow to call a function=20
>> without parenthesis.
>> I'm pretty sure some people already have some use cases for this kind of=
=20
>> features like static analysis of the code.
>>
>> The pitfall I can see with this are the following:
>>
>> - With the previous rules, myobj =3D expr; would call the operator=20
>> void() because the operator=3D() returns a reference to the object=20
>> which is not used.
>>
>> A solution to this could be to not return a reference to the object afte=
r=20
>> an affectation (this breaks the affectation chaining) or return a wrappe=
r=20
>> to the reference (add boilerplate).
>>
>> --=20
>> 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/3cb45c49-fc=
41-4922-b35c-49871dd00a54%40isocpp.org=20
>> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/3cb45c49-f=
c41-4922-b35c-49871dd00a54%40isocpp.org?utm_medium=3Demail&utm_source=3Dfoo=
ter>
>> .
>>
>
> If you don't even have one practical example of how this would be useful=
=20
> then I don't know why you would expect the committee to spend time=20
> considering it.
>
> Other proposals, like "regular void", could make use of operator void in=
=20
> ways that conflict with your idea.
>
>
To be honest with you, I had thought about some use-cases when I came up=20
with this idea, but forgot them while thinking about the shape this could=
=20
have.
In fact, I wouldn't have published this if I hadn't seen the post about the=
=20
semi-colon operator overloading (which is basically the same idea, but a=20
little different).
A really easy use case is to have an hard error when an object is returned=
=20
and never used. There are other proposal to this very use case. This is=20
another approach (which can be used for other things).
--=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/e7310ca2-68d5-4d42-9d33-bfee31d97c72%40isocpp.or=
g.
------=_Part_570_354768455.1488903321795
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><br>Le mardi 7 mars 2017 17:05:31 UTC+1, Brittany Frie=
dman a =C3=A9crit=C2=A0:<blockquote class=3D"gmail_quote" style=3D"margin: =
0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div d=
ir=3D"ltr"><div><div class=3D"gmail_quote">On Tue, Mar 7, 2017 at 9:56 AM, =
<span dir=3D"ltr"><<a href=3D"javascript:" target=3D"_blank" gdf-obfusc=
ated-mailto=3D"qqq3XaeMCwAJ" rel=3D"nofollow" onmousedown=3D"this.href=3D&#=
39;javascript:';return true;" onclick=3D"this.href=3D'javascript:&#=
39;;return true;">floria...@gmail.com</a>></span> wrote:<br><blockquote =
class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px sol=
id rgb(204,204,204);padding-left:1ex"><div dir=3D"ltr">For now, <span style=
=3D"background-color:rgb(238,238,238)"><span style=3D"font-family:"cou=
rier new",monospace">operator void()</span></span> is allowed but neve=
r used (unless explicitly called with <span style=3D"background-color:rgb(2=
38,238,238)"><span style=3D"font-family:"courier new",monospace">=
obj.operator void()</span></span> ).<br>I propose to add a meaning to this =
conversion operator: it is called when ever the result of an expression isn=
't used.<br>First, this is not the same as calling the destructor on a =
temporary object.<br><br>This would allow to call a specific function with =
that kind of syntax:<br><div style=3D"background-color:rgb(250,250,250);bor=
der-color:rgb(187,187,187);border-style:solid;border-width:1px;word-wrap:br=
eak-word"><code><div><div style=3D"background-color:rgb(250,250,250);border=
-color:rgb(187,187,187);border-style:solid;border-width:1px;word-wrap:break=
-word"><code><div><span style=3D"color:rgb(0,0,0)">myobj;<br>myobj</span><s=
pan style=3D"color:rgb(102,102,0)">.</span><span style=3D"color:rgb(0,0,0)"=
>mymember</span><span style=3D"color:rgb(102,102,0)">;<br></span></div></co=
de></div><span style=3D"color:rgb(102,102,0)"></span></div></code></div><br=
>Basically, if the result of an expression is not used, it calls the (<i>im=
plicit</i>) <span style=3D"font-family:"times new roman",serif"><=
span style=3D"background-color:rgb(238,238,238)"><span style=3D"font-family=
:"courier new",monospace">operator void()</span></span></span><sp=
an style=3D"font-family:"times new roman",serif"><span style=3D"b=
ackground-color:rgb(238,238,238)"><span style=3D"font-family:"courier =
new",monospace"></span></span></span>.<br>If you write <span style=3D"=
font-family:"courier new",monospace"><span style=3D"background-co=
lor:rgb(238,238,238)">(void) myobj</span></span> or <span style=3D"font-fam=
ily:"courier new",monospace"><span style=3D"background-color:rgb(=
238,238,238)">static_cast<void>(myobj)</span></span>, it calls the ex=
plicit <span style=3D"font-family:"courier new",monospace"><span =
style=3D"background-color:rgb(238,238,238)">operator void()</span></span>.<=
br>If you write <span style=3D"background-color:rgb(238,238,238)"><span sty=
le=3D"font-family:"courier new",monospace">reinterpret_cast<vo=
id>(myobj)</span></span>, nothing happens: <b>no</b> <span style=3D"font=
-family:"courier new",monospace"><span style=3D"background-color:=
rgb(238,238,238)">operator void()</span></span> is called.<br>If the <span =
style=3D"background-color:rgb(238,238,238)"><span style=3D"font-family:&quo=
t;courier new",monospace">operator void()</span></span> should be call=
ed but doesn't exist, nothing happens: <b>no</b> <span style=3D"font-fa=
mily:"courier new",monospace"><span style=3D"background-color:rgb=
(238,238,238)">operator void()</span></span> is called.<br>If the <span sty=
le=3D"background-color:rgb(238,238,238)"><span style=3D"font-family:"c=
ourier new",monospace">operator void()</span></span> should be called =
but is <span style=3D"background-color:rgb(238,238,238)"><span style=3D"fon=
t-family:"courier new",monospace">delete</span></span>d: the prog=
ram is ill-formed.<br>If a function parameter is not used within the functi=
on body, nothing happens: <b>no</b> <span style=3D"font-family:"courie=
r new",monospace"><span style=3D"background-color:rgb(238,238,238)">op=
erator void()</span></span> is called.<br><br>I'm not sure what kind of=
uses this can have, but this would add a meaning to something that is alre=
ady syntactically valid (you already can write <span style=3D"font-family:&=
quot;courier new",monospace"><span style=3D"background-color:rgb(238,2=
38,238)">operator void()</span></span> ), and some languages allow to call =
a function without parenthesis.<br>I'm pretty sure some people already =
have some use cases for this kind of features like static analysis of the c=
ode.<br><br>The pitfall I can see with this are the following:<br><ul><li>W=
ith the previous rules, <span style=3D"font-family:"courier new",=
monospace"><span style=3D"background-color:rgb(238,238,238)">myobj =3D expr=
;</span></span> would call the <span style=3D"background-color:rgb(238,238,=
238)"><span style=3D"font-family:"courier new",monospace">operato=
r void()</span></span> because the <span style=3D"background-color:rgb(238,=
238,238)"><span style=3D"font-family:"courier new",monospace">ope=
rator=3D()</span></span> returns a reference to the object which is not use=
d.</li></ul>A solution to this could be to not return a reference to the ob=
ject after an affectation (this breaks the affectation chaining) or return =
a wrapper to the reference (add boilerplate).<span><font color=3D"#888888">=
<br></font></span></div><span><font color=3D"#888888">
<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"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"=
qqq3XaeMCwAJ" 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"qqq3XaeMCwAJ" 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>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/3cb45c49-fc41-4922-b35c-49871dd00a54%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter" target=3D"_blank" =
rel=3D"nofollow" onmousedown=3D"this.href=3D'https://groups.google.com/=
a/isocpp.org/d/msgid/std-proposals/3cb45c49-fc41-4922-b35c-49871dd00a54%40i=
socpp.org?utm_medium\x3demail\x26utm_source\x3dfooter';return true;" on=
click=3D"this.href=3D'https://groups.google.com/a/isocpp.org/d/msgid/st=
d-proposals/3cb45c49-fc41-4922-b35c-49871dd00a54%40isocpp.org?utm_medium\x3=
demail\x26utm_source\x3dfooter';return true;">https://groups.google.com=
/a/<wbr>isocpp.org/d/msgid/std-<wbr>proposals/3cb45c49-fc41-4922-<wbr>b35c-=
49871dd00a54%40isocpp.org</a><wbr>.<br></font></span></blockquote><div><br>=
</div><div>If you don't even have one practical example of how this wou=
ld be useful then I don't know why you would expect the committee to sp=
end time considering it.</div><div><br></div><div>Other proposals, like &qu=
ot;regular void", could make use of operator void in ways that conflic=
t with your idea.</div></div><br></div></div></blockquote><div><br>To be ho=
nest with you, I had thought about some use-cases when I came up with this =
idea, but forgot them while thinking about the shape this could have.<br>In=
fact, I wouldn't have published this if I hadn't seen the post abo=
ut the semi-colon operator overloading (which is basically the same idea, b=
ut a little different).<br><br>A really easy use case is to have an hard er=
ror when an object is returned and never used. There are other proposal to =
this very use case. This is another approach (which can be used for other t=
hings).<br></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/e7310ca2-68d5-4d42-9d33-bfee31d97c72%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/e7310ca2-68d5-4d42-9d33-bfee31d97c72=
%40isocpp.org</a>.<br />
------=_Part_570_354768455.1488903321795--
------=_Part_569_450392758.1488903321794--
.
Author: Dan Raviv <dan.raviv@gmail.com>
Date: Tue, 7 Mar 2017 09:55:51 -0800 (PST)
Raw View
------=_Part_496_163864976.1488909351911
Content-Type: multipart/alternative;
boundary="----=_Part_497_641384048.1488909351911"
------=_Part_497_641384048.1488909351911
Content-Type: text/plain; charset=UTF-8
> A really easy use case is to have an hard error when an object is returned
> and never used. There are other proposal to this very use case. This is
> another approach (which can be used for other things).
>
For that specific use case, you have the new [[nodiscard]] attribute.
--
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/ea3b0cae-0155-4e81-8b66-b6b27be04c0a%40isocpp.org.
------=_Part_497_641384048.1488909351911
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><blockquote class=3D"gmail_quote" style=3D"margin: 0;m=
argin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=
=3D"ltr"><div>A really easy use case is to have an hard error when an objec=
t is returned and never used. There are other proposal to this very use cas=
e. This is another approach (which can be used for other things).<br></div>=
</div></blockquote><div><br></div><div>For that specific use case, you have=
the new [[nodiscard]] attribute.</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/ea3b0cae-0155-4e81-8b66-b6b27be04c0a%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/ea3b0cae-0155-4e81-8b66-b6b27be04c0a=
%40isocpp.org</a>.<br />
------=_Part_497_641384048.1488909351911--
------=_Part_496_163864976.1488909351911--
.
Author: =?UTF-8?Q?=27Thomas_K=C3=B6ppe=27_via_ISO_C=2B=2B_Standard_=2D_Future_Proposals?= <std-proposals@isocpp.org>
Date: Fri, 10 Mar 2017 20:38:59 -0800 (PST)
Raw View
------=_Part_5222_218777304.1489207139426
Content-Type: multipart/alternative;
boundary="----=_Part_5223_188705243.1489207139426"
------=_Part_5223_188705243.1489207139426
Content-Type: text/plain; charset=UTF-8
Perhaps you could avoid a few complications if you restricted your design
to prvalue expressions only. Then things like assignment operators wouldn't
all require exceptional treatment, for example.
--
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/cca3ecb8-fd00-4338-a4d8-dd8e18f67c74%40isocpp.org.
------=_Part_5223_188705243.1489207139426
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Perhaps you could avoid a few complications if you restric=
ted your design to prvalue expressions only. Then things like assignment op=
erators wouldn't all require exceptional treatment, for example.</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/cca3ecb8-fd00-4338-a4d8-dd8e18f67c74%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/cca3ecb8-fd00-4338-a4d8-dd8e18f67c74=
%40isocpp.org</a>.<br />
------=_Part_5223_188705243.1489207139426--
------=_Part_5222_218777304.1489207139426--
.