Topic: Let's overload the semicolon!


Author: Derek Ross <antiquarktv@gmail.com>
Date: Fri, 15 Jul 2016 19:27:24 -0700 (PDT)
Raw View
------=_Part_967_641235918.1468636044459
Content-Type: multipart/alternative;
 boundary="----=_Part_968_1527073806.1468636044460"

------=_Part_968_1527073806.1468636044460
Content-Type: text/plain; charset=UTF-8

Maybe I should have waited until April 1st before posting this... but is
this a good idea? Seems to be OK to me.  If something like this existed
decades ago, I would have used it many many times by now (unless there's
some "gotcha" I missed)...

Let's put a new operator into C++: the "terminator operator." It would look
like this: ';' (a semicolon). It would be a unary postfix operator with a
lower precedence than the comma operator.

A class can overload the terminator operator by defining a member function
like:

 void operator;(){
   ..etc..
 }

The purpose of the terminator operator is to perform some action when a
sequence of operations reaches the statement terminator. If a terminator
operator isn't defined for an object, then nothing special happens.

One application would be automatic buffer flushing for a logging function.
For example, a conventional call to the C function syslog:

 syslog(LOG_ERR, "The value is %d", value);
 syslog(LOG_INFO, "The device is %s", dev);

could be replaced with a C++ Syslog object along with overloaded operators:

 Syslog << Log_Err << "The value is " << value ;
 Syslog << Log_Info << "The device is " << dev ;

The CSyslog class would use the terminator operator to trigger the
transmission of the buffered data to the syslog daemon (probably through an
internal call to ::syslog().)

Below is a slightly more fleshed-out example, of a cout-styled facility
that automatically appends a newline at the end of the statement, like
Java's "println" function.


struct CoutLn
{
    // Typical inserter function.
    CoutLn& operator<<(const char* x)
    {
        cout << x;
        return *this;
    }

    // Terminator operator.
    // Send a newline to the console at
    // statement termination.
    void  operator;()
    {
        cout << '\n';
    }

    // Manipulator to ignore the next
    // terminator.
    const static struct SkipNl {} skipnl;

    // Return void on SkipNl, thus
    // "deactivating" the subsequent
    // terminator operator.
    void operator<<(const SkipNl){}

} coutln;

int main()
{
    coutln << "A" ;                   // Prints "A\n"
    coutln << "B" << CoutLn::skipnl ; // Prints "B"
}



--
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/1d0db2d2-41be-4c3c-95be-6a247d223f99%40isocpp.org.

------=_Part_968_1527073806.1468636044460
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Maybe I should have waited until April 1st before posting =
this... but is this a good idea? Seems to be OK to me.=C2=A0 If something l=
ike this existed decades ago, I would have used it many many times by now (=
unless there&#39;s some &quot;gotcha&quot; I missed)...<br><br>Let&#39;s pu=
t a new operator into C++: the &quot;terminator operator.&quot; It would lo=
ok like this: &#39;;&#39; (a semicolon). It would be a unary postfix operat=
or with a lower precedence than the comma operator. <br><br>A class can ove=
rload the terminator operator by defining a member function like: <br><br><=
div class=3D"prettyprint" style=3D"background-color: rgb(250, 250, 250); bo=
rder-color: rgb(187, 187, 187); border-style: solid; border-width: 1px; wor=
d-wrap: break-word;"><code class=3D"prettyprint"><div class=3D"subprettypri=
nt"><span style=3D"color: #000;" class=3D"styled-by-prettify">=C2=A0</span>=
<span style=3D"color: #008;" class=3D"styled-by-prettify">void</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"=
color: #008;" class=3D"styled-by-prettify">operator</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">;(){</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">..</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify">etc</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">..</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"><br>=C2=A0</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">}</span></div></code></div><br>The purpose of the termin=
ator operator is to perform some action when a sequence of operations reach=
es the statement terminator. If a terminator operator isn&#39;t defined for=
 an object, then nothing special happens. <br><br>One application would be =
automatic buffer flushing for a logging function. For example, a convention=
al call to the C function syslog:<br><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;"><code clas=
s=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"color: #000;=
" class=3D"styled-by-prettify">=C2=A0syslog</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">LOG_ERR</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> </span><span style=3D"color: #080;" class=3D"styled-by-prettif=
y">&quot;The value is %d&quot;</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> value</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">);</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
<br>=C2=A0syslog</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">LOG=
_INFO</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span =
style=3D"color: #080;" class=3D"styled-by-prettify">&quot;The device is %s&=
quot;</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"> dev</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">);</span></div></cod=
e></div>=C2=A0<br>could be replaced with a C++ Syslog object along with ove=
rloaded operators:<br><br><div class=3D"prettyprint" style=3D"background-co=
lor: rgb(250, 250, 250); border-color: rgb(187, 187, 187); border-style: so=
lid; border-width: 1px; word-wrap: break-word;"><code class=3D"prettyprint"=
><div class=3D"subprettyprint"><span style=3D"color: #000;" class=3D"styled=
-by-prettify">=C2=A0</span><span style=3D"color: #606;" class=3D"styled-by-=
prettify">Syslog</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt=
;&lt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span style=3D"color: #606;" class=3D"styled-by-prettify">Log_Err</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt;</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #080;" class=3D"styled-by-prettify">&quot;The value is &quot;</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">&lt;&lt;</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> value </span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;"=
 class=3D"styled-by-prettify"><br>=C2=A0</span><span style=3D"color: #606;"=
 class=3D"styled-by-prettify">Syslog</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">&lt;&lt;</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> </span><span style=3D"color: #606;" class=3D"styled-by-pret=
tify">Log_Info</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&=
lt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span style=3D"color: #080;" class=3D"styled-by-prettify">&quot;The device=
 is &quot;</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
 </span><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt;<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> dev </span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span></div></=
code></div><br>The CSyslog class would use the terminator operator to trigg=
er the transmission of the buffered data to the syslog daemon (probably thr=
ough an internal call to ::syslog().)<br>=C2=A0<br>Below is a slightly more=
 fleshed-out example, of a cout-styled facility that automatically appends =
a newline at the end of the statement, like Java&#39;s &quot;println&quot; =
function. <br><br><div class=3D"prettyprint" style=3D"background-color: rgb=
(250, 250, 250); border-color: rgb(187, 187, 187); border-style: solid; bor=
der-width: 1px; word-wrap: break-word;"><code class=3D"prettyprint"><div cl=
ass=3D"subprettyprint"><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"><br></span><span style=3D"color: #008;" class=3D"styled-by-prettify">=
struct</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </s=
pan><span style=3D"color: #606;" class=3D"styled-by-prettify">CoutLn</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> =C2=A0 =C2=A0 =C2=A0 =C2=A0 <br=
>=C2=A0 =C2=A0 </span><span style=3D"color: #800;" class=3D"styled-by-prett=
ify">// Typical inserter function. </span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><span style=3D"color: #60=
6;" class=3D"styled-by-prettify">CoutLn</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">&amp;</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"style=
d-by-prettify">operator</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">&lt;&lt;(</span><span style=3D"color: #008;" class=3D"styled-b=
y-prettify">const</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">ch=
ar</span><span style=3D"color: #660;" class=3D"styled-by-prettify">*</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> x</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">)</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 cou=
t </span><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt;=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> x</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =
=C2=A0 </span><span style=3D"color: #008;" class=3D"styled-by-prettify">ret=
urn</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">*</span><span st=
yle=3D"color: #008;" class=3D"styled-by-prettify">this</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">}</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 <br>=C2=A0 =C2=A0 </spa=
n><span style=3D"color: #800;" class=3D"styled-by-prettify">// Terminator o=
perator. </span><span style=3D"color: #000;" class=3D"styled-by-prettify"><=
br>=C2=A0 =C2=A0 </span><span style=3D"color: #800;" class=3D"styled-by-pre=
ttify">// Send a newline to the console at</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><span style=3D"col=
or: #800;" class=3D"styled-by-prettify">// statement termination. </span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 <=
/span><span style=3D"color: #008;" class=3D"styled-by-prettify">void</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> =C2=A0</span><sp=
an style=3D"color: #008;" class=3D"styled-by-prettify">operator</span><span=
 style=3D"color: #660;" class=3D"styled-by-prettify">;()</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=
=A0 cout </span><span style=3D"color: #660;" class=3D"styled-by-prettify">&=
lt;&lt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </=
span><span style=3D"color: #080;" class=3D"styled-by-prettify">&#39;\n&#39;=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> =C2=A0 =C2=A0 =C2=
=A0 =C2=A0<br>=C2=A0 =C2=A0 </span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">}</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"><br>=C2=A0 =C2=A0 <br>=C2=A0 =C2=A0 </span><span style=3D"color: #=
800;" class=3D"styled-by-prettify">// Manipulator to ignore the next </span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=
=A0 </span><span style=3D"color: #800;" class=3D"styled-by-prettify">// ter=
minator. </span><span style=3D"color: #000;" class=3D"styled-by-prettify"><=
br>=C2=A0 =C2=A0 </span><span style=3D"color: #008;" class=3D"styled-by-pre=
ttify">const</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">static<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><sp=
an style=3D"color: #008;" class=3D"styled-by-prettify">struct</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"c=
olor: #606;" class=3D"styled-by-prettify">SkipNl</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">{}</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"> skipnl</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> <br>=C2=A0 =C2=A0 <br>=C2=A0 =C2=A0 </span><span style=3D"color: =
#800;" class=3D"styled-by-prettify">// Return void on SkipNl, thus</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 <=
/span><span style=3D"color: #800;" class=3D"styled-by-prettify">// &quot;de=
activating&quot; the subsequent </span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><span style=3D"color: #800=
;" class=3D"styled-by-prettify">// terminator operator. </span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><sp=
an style=3D"color: #008;" class=3D"styled-by-prettify">void</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"col=
or: #008;" class=3D"styled-by-prettify">operator</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">&lt;&lt;(</span><span style=3D"color:=
 #008;" class=3D"styled-by-prettify">const</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> </span><span style=3D"color: #606;" class=
=3D"styled-by-prettify">SkipNl</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">){}</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"><br>=C2=A0 =C2=A0 <br></span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">}</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> coutln</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"><br><br></span><span style=3D"color: #008;" class=3D"styled-by-prettify=
">int</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> main=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">()</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> =C2=A0 =C2=A0<br>=C2=A0 =C2=A0 c=
outln </span><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;=
&lt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </spa=
n><span style=3D"color: #080;" class=3D"styled-by-prettify">&quot;A&quot;</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> =C2=A0 =C2=A0 =C2=A0 =C2=A0=
 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color: #800;" cla=
ss=3D"styled-by-prettify">// Prints &quot;A\n&quot; </span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 coutln </span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt;</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #080;" class=3D"styled-by-prettify">&quot;B&quot;</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">&lt;&lt;</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #606;"=
 class=3D"styled-by-prettify">CoutLn</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">::</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify">skipnl </span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> </span><span style=3D"color: #800;" class=3D"styled-by-prettify">// =
Prints &quot;B&quot; =C2=A0 =C2=A0</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br></span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">}</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"><br><br></span></div></code></div><br><br></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/1d0db2d2-41be-4c3c-95be-6a247d223f99%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/1d0db2d2-41be-4c3c-95be-6a247d223f99=
%40isocpp.org</a>.<br />

------=_Part_968_1527073806.1468636044460--

------=_Part_967_641235918.1468636044459--

.


Author: "D. B." <db0451@gmail.com>
Date: Sat, 16 Jul 2016 10:04:43 +0100
Raw View
--089e011779d1b612b80537bd068d
Content-Type: text/plain; charset=UTF-8

When one could trivially make a tag struct to perform the same purpose
(e.g. std::endl), overloading the statement delimiter to save typing a few
characters looks absurd to me
 - born of overinterpretation of DRY, potentially very dangerous, and
doesn't explain how to handle situations where you want to output a bit
now, do some more calculation, then output the endl/flush/whatever later.
What, would you prefer to write 2 classes for every situation, one with the
semicolon overloaded and one without?

What's wrong with
Syslog << Log_Err << "The value is " << value << SLgo; // or any other tag

and really now:
    coutln << "A" ;                   // Prints "A\n"
    coutln << "B" << CoutLn::skipnl ; // Prints "B"
That's more typing than one line with std::endl and one without, but the
latter isn't completely inverse (perverse?) to intuition.

The real solution is to use tag structs OR a non-inserting operator/call
(that processes a full 'statement' of output at a time a la printf).
Neither of which semantically break the language for the sake of saving a
few keystrokes in the few situations to which they're barely applicavble.

--
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/CACGiwhE8Jj3B3-rcS4vV%3DXsaKaXghEez8mUig4AB423KHXpx%2Bw%40mail.gmail.com.

--089e011779d1b612b80537bd068d
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div><div><div>When one could trivially make a tag struct =
to perform the same purpose (e.g. std::endl), overloading the statement del=
imiter to save typing a few characters looks absurd to me<br>=C2=A0- born o=
f overinterpretation of DRY, potentially very dangerous, and doesn&#39;t ex=
plain how to handle situations where you want to output a bit now, do some =
more calculation, then output the endl/flush/whatever later. What, would yo=
u prefer to write 2 classes for every situation, one with the semicolon ove=
rloaded and one without?<br><br></div><div>What&#39;s wrong with <br><code>=
<span style=3D"color:rgb(102,0,102)">Syslog</span><span style=3D"color:rgb(=
0,0,0)"> </span><span style=3D"color:rgb(102,102,0)">&lt;&lt;</span><span s=
tyle=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(102,0,102)">Log_=
Err</span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb=
(102,102,0)">&lt;&lt;</span><span style=3D"color:rgb(0,0,0)"> </span><span =
style=3D"color:rgb(0,136,0)">&quot;The value is &quot;</span><span style=3D=
"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(102,102,0)">&lt;&lt;</s=
pan><span style=3D"color:rgb(0,0,0)"> value </span><span style=3D"color:rgb=
(102,102,0)">&lt;&lt; SLgo;</span></code> // or any other tag<br></div><div=
><br></div>and really now:<code><span style=3D"color:rgb(0,0,0)"><br>=C2=A0=
 =C2=A0 coutln </span><span style=3D"color:rgb(102,102,0)">&lt;&lt;</span><=
span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(0,136,0)">=
&quot;A&quot;</span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D=
"color:rgb(102,102,0)">;</span><span style=3D"color:rgb(0,0,0)"> =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"=
color:rgb(136,0,0)">// Prints &quot;A\n&quot; </span><span style=3D"color:r=
gb(0,0,0)"><br>=C2=A0 =C2=A0 coutln </span><span style=3D"color:rgb(102,102=
,0)">&lt;&lt;</span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D=
"color:rgb(0,136,0)">&quot;B&quot;</span><span style=3D"color:rgb(0,0,0)"> =
</span><span style=3D"color:rgb(102,102,0)">&lt;&lt;</span><span style=3D"c=
olor:rgb(0,0,0)"> </span><span style=3D"color:rgb(102,0,102)">CoutLn</span>=
<span style=3D"color:rgb(102,102,0)">::</span><span style=3D"color:rgb(0,0,=
0)">skipnl </span><span style=3D"color:rgb(102,102,0)">;</span><span style=
=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(136,0,0)">// Prints =
&quot;B&quot; =C2=A0=C2=A0 </span><span style=3D"color:rgb(0,0,0)"><br></sp=
an></code></div><code><span style=3D"color:rgb(0,0,0)"><span style=3D"font-=
family:arial,helvetica,sans-serif"><font size=3D"2">That&#39;s more typing =
than one line with std::endl and one without, but the latter isn&#39;t comp=
letely inverse (perverse?) to intuition.</font></span><br><span style=3D"fo=
nt-family:arial,helvetica,sans-serif"><br></span></span></code></div><code>=
<span style=3D"color:rgb(0,0,0)"><span style=3D"font-family:arial,helvetica=
,sans-serif">The real solution is to use tag structs OR a non-inserting ope=
rator/call (that processes a full &#39;statement&#39; of output at a time a=
 la printf). Neither of which semantically break the language for the sake =
of saving a few keystrokes in the few situations to which they&#39;re barel=
y applicavble.</span><br></span></code></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/CACGiwhE8Jj3B3-rcS4vV%3DXsaKaXghEez8m=
Uig4AB423KHXpx%2Bw%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter"=
>https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CACGiwhE8Jj3B=
3-rcS4vV%3DXsaKaXghEez8mUig4AB423KHXpx%2Bw%40mail.gmail.com</a>.<br />

--089e011779d1b612b80537bd068d--

.


Author: Wil Evers <wileversmod@gmail.com>
Date: Sat, 16 Jul 2016 11:12:49 -0700 (PDT)
Raw View
------=_Part_233_155294336.1468692770075
Content-Type: multipart/alternative;
 boundary="----=_Part_234_2025230788.1468692770075"

------=_Part_234_2025230788.1468692770075
Content-Type: text/plain; charset=UTF-8



On Saturday, July 16, 2016 at 4:27:24 AM UTC+2, Derek Ross wrote:
>
> Maybe I should have waited until April 1st before posting this... but is
> this a good idea? Seems to be OK to me.  If something like this existed
> decades ago, I would have used it many many times by now (unless there's
> some "gotcha" I missed)...
>
> Let's put a new operator into C++: the "terminator operator." It would
> look like this: ';' (a semicolon). It would be a unary postfix operator
> with a lower precedence than the comma operator.
>
> A class can overload the terminator operator by defining a member function
> like:
>
>  void operator;(){
>    ..etc..
>  }
>
> The purpose of the terminator operator is to perform some action when a
> sequence of operations reaches the statement terminator. If a terminator
> operator isn't defined for an object, then nothing special happens.
>

C++ already has this; the destructors of temporaries are called at the 'end
of full expression', that is, the semicolon.

Wil



--
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/6c8a938f-6571-45c2-9d96-2b61b8c80ed3%40isocpp.org.

------=_Part_234_2025230788.1468692770075
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><br>On Saturday, July 16, 2016 at 4:27:24 AM UTC+2, De=
rek Ross wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-=
left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr=
">Maybe I should have waited until April 1st before posting this... but is =
this a good idea? Seems to be OK to me.=C2=A0 If something like this existe=
d decades ago, I would have used it many many times by now (unless there&#3=
9;s some &quot;gotcha&quot; I missed)...<br><br>Let&#39;s put a new operato=
r into C++: the &quot;terminator operator.&quot; It would look like this: &=
#39;;&#39; (a semicolon). It would be a unary postfix operator with a lower=
 precedence than the comma operator. <br><br>A class can overload the termi=
nator operator by defining a member function like: <br><br><div style=3D"ba=
ckground-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"colo=
r:#000">=C2=A0</span><span style=3D"color:#008">void</span><span style=3D"c=
olor:#000"> </span><span style=3D"color:#008">operator</span><span style=3D=
"color:#660">;(){</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0</span>=
<span style=3D"color:#660">..</span><span style=3D"color:#000">etc</span><s=
pan style=3D"color:#660">..</span><span style=3D"color:#000"><br>=C2=A0</sp=
an><span style=3D"color:#660">}</span></div></code></div><br>The purpose of=
 the terminator operator is to perform some action when a sequence of opera=
tions reaches the statement terminator. If a terminator operator isn&#39;t =
defined for an object, then nothing special happens. <br></div></blockquote=
><div><br>C++ already has this; the destructors of temporaries are called a=
t the &#39;end of full expression&#39;, that is, the semicolon.<br><br>Wil<=
br>=C2=A0<br></div><div>=C2=A0</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/6c8a938f-6571-45c2-9d96-2b61b8c80ed3%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/6c8a938f-6571-45c2-9d96-2b61b8c80ed3=
%40isocpp.org</a>.<br />

------=_Part_234_2025230788.1468692770075--

------=_Part_233_155294336.1468692770075--

.


Author: Vishal Oza <vickoza@gmail.com>
Date: Sat, 16 Jul 2016 12:01:19 -0700 (PDT)
Raw View
------=_Part_2864_1581232004.1468695679431
Content-Type: multipart/alternative;
 boundary="----=_Part_2865_2002104156.1468695679432"

------=_Part_2865_2002104156.1468695679432
Content-Type: text/plain; charset=UTF-8

I also think overloading the semicolon operator is a bad idea as it could
lead to breaking changes in you entire code base as well as confusing code.
However, I could see a value in static analyzer.  I think a better solution
might be a either have expression types-traits or introduce custom operator
definition where you define first the the operator, the syntax then
optionally the level of precedence, and the then operator overload most
common C++ operators would be exempt from this definition. This should also
by uncommon looking like C++ lamba notations so it does not break existing
code.

On Friday, July 15, 2016 at 9:27:24 PM UTC-5, Derek Ross wrote:
>
> Maybe I should have waited until April 1st before posting this... but is
> this a good idea? Seems to be OK to me.  If something like this existed
> decades ago, I would have used it many many times by now (unless there's
> some "gotcha" I missed)...
>
> Let's put a new operator into C++: the "terminator operator." It would
> look like this: ';' (a semicolon). It would be a unary postfix operator
> with a lower precedence than the comma operator.
>
> A class can overload the terminator operator by defining a member function
> like:
>
>  void operator;(){
>    ..etc..
>  }
>
> The purpose of the terminator operator is to perform some action when a
> sequence of operations reaches the statement terminator. If a terminator
> operator isn't defined for an object, then nothing special happens.
>
> One application would be automatic buffer flushing for a logging function.
> For example, a conventional call to the C function syslog:
>
>  syslog(LOG_ERR, "The value is %d", value);
>  syslog(LOG_INFO, "The device is %s", dev);
>
> could be replaced with a C++ Syslog object along with overloaded operators:
>
>  Syslog << Log_Err << "The value is " << value ;
>  Syslog << Log_Info << "The device is " << dev ;
>
> The CSyslog class would use the terminator operator to trigger the
> transmission of the buffered data to the syslog daemon (probably through an
> internal call to ::syslog().)
>
> Below is a slightly more fleshed-out example, of a cout-styled facility
> that automatically appends a newline at the end of the statement, like
> Java's "println" function.
>
>
> struct CoutLn
> {
>     // Typical inserter function.
>     CoutLn& operator<<(const char* x)
>     {
>         cout << x;
>         return *this;
>     }
>
>     // Terminator operator.
>     // Send a newline to the console at
>     // statement termination.
>     void  operator;()
>     {
>         cout << '\n';
>     }
>
>     // Manipulator to ignore the next
>     // terminator.
>     const static struct SkipNl {} skipnl;
>
>     // Return void on SkipNl, thus
>     // "deactivating" the subsequent
>     // terminator operator.
>     void operator<<(const SkipNl){}
>
> } coutln;
>
> int main()
> {
>     coutln << "A" ;                   // Prints "A\n"
>     coutln << "B" << CoutLn::skipnl ; // Prints "B"
> }
>
>
>
>

--
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/5245fce2-adb0-4ca8-b9ac-f852f3025412%40isocpp.org.

------=_Part_2865_2002104156.1468695679432
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">I also think overloading the semicolon operator is a bad i=
dea as it could lead to breaking changes in you entire code base as well as=
 confusing code. However, I could see a value in static analyzer. =C2=A0I t=
hink a better solution might be a either have expression types-traits or in=
troduce custom operator definition where you define first the the operator,=
 the syntax then optionally the level of precedence, and the then operator =
overload most common C++ operators would be exempt from this definition. Th=
is should also by uncommon looking like C++ lamba notations so it does not =
break existing code.<br><br>On Friday, July 15, 2016 at 9:27:24 PM UTC-5, D=
erek Ross wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin=
-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"lt=
r">Maybe I should have waited until April 1st before posting this... but is=
 this a good idea? Seems to be OK to me.=C2=A0 If something like this exist=
ed decades ago, I would have used it many many times by now (unless there&#=
39;s some &quot;gotcha&quot; I missed)...<br><br>Let&#39;s put a new operat=
or into C++: the &quot;terminator operator.&quot; It would look like this: =
&#39;;&#39; (a semicolon). It would be a unary postfix operator with a lowe=
r precedence than the comma operator. <br><br>A class can overload the term=
inator operator by defining a member function like: <br><br><div style=3D"b=
ackground-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"col=
or:#000">=C2=A0</span><span style=3D"color:#008">void</span><span style=3D"=
color:#000"> </span><span style=3D"color:#008">operator</span><span style=
=3D"color:#660">;(){</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0</sp=
an><span style=3D"color:#660">..</span><span style=3D"color:#000">etc</span=
><span style=3D"color:#660">..</span><span style=3D"color:#000"><br>=C2=A0<=
/span><span style=3D"color:#660">}</span></div></code></div><br>The purpose=
 of the terminator operator is to perform some action when a sequence of op=
erations reaches the statement terminator. If a terminator operator isn&#39=
;t defined for an object, then nothing special happens. <br><br>One applica=
tion would be automatic buffer flushing for a logging function. For example=
, a conventional call to the C function syslog:<br><br><div style=3D"backgr=
ound-color:rgb(250,250,250);border-color:rgb(187,187,187);border-style:soli=
d;border-width:1px;word-wrap:break-word"><code><div><span style=3D"color:#0=
00">=C2=A0syslog</span><span style=3D"color:#660">(</span><span style=3D"co=
lor:#000">LOG_ERR</span><span style=3D"color:#660">,</span><span style=3D"c=
olor:#000"> </span><span style=3D"color:#080">&quot;The value is %d&quot;</=
span><span style=3D"color:#660">,</span><span style=3D"color:#000"> value</=
span><span style=3D"color:#660">);</span><span style=3D"color:#000"> <br>=
=C2=A0syslog</span><span style=3D"color:#660">(</span><span style=3D"color:=
#000">LOG_INFO</span><span style=3D"color:#660">,</span><span style=3D"colo=
r:#000"> </span><span style=3D"color:#080">&quot;The device is %s&quot;</sp=
an><span style=3D"color:#660">,</span><span style=3D"color:#000"> dev</span=
><span style=3D"color:#660">);</span></div></code></div>=C2=A0<br>could be =
replaced with a C++ Syslog object along with overloaded operators:<br><br><=
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><spa=
n style=3D"color:#000">=C2=A0</span><span style=3D"color:#606">Syslog</span=
><span style=3D"color:#000"> </span><span style=3D"color:#660">&lt;&lt;</sp=
an><span style=3D"color:#000"> </span><span style=3D"color:#606">Log_Err</s=
pan><span style=3D"color:#000"> </span><span style=3D"color:#660">&lt;&lt;<=
/span><span style=3D"color:#000"> </span><span style=3D"color:#080">&quot;T=
he value is &quot;</span><span style=3D"color:#000"> </span><span style=3D"=
color:#660">&lt;&lt;</span><span style=3D"color:#000"> value </span><span s=
tyle=3D"color:#660">;</span><span style=3D"color:#000"><br>=C2=A0</span><sp=
an style=3D"color:#606">Syslog</span><span style=3D"color:#000"> </span><sp=
an style=3D"color:#660">&lt;&lt;</span><span style=3D"color:#000"> </span><=
span style=3D"color:#606">Log_Info</span><span style=3D"color:#000"> </span=
><span style=3D"color:#660">&lt;&lt;</span><span style=3D"color:#000"> </sp=
an><span style=3D"color:#080">&quot;The device is &quot;</span><span style=
=3D"color:#000"> </span><span style=3D"color:#660">&lt;&lt;</span><span sty=
le=3D"color:#000"> dev </span><span style=3D"color:#660">;</span></div></co=
de></div><br>The CSyslog class would use the terminator operator to trigger=
 the transmission of the buffered data to the syslog daemon (probably throu=
gh an internal call to ::syslog().)<br>=C2=A0<br>Below is a slightly more f=
leshed-out example, of a cout-styled facility that automatically appends a =
newline at the end of the statement, like Java&#39;s &quot;println&quot; fu=
nction. <br><br><div 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><div><span style=3D"color:#000"><br></span><span style=3D"color:#00=
8">struct</span><span style=3D"color:#000"> </span><span style=3D"color:#60=
6">CoutLn</span><span style=3D"color:#000"><br></span><span style=3D"color:=
#660">{</span><span style=3D"color:#000"> =C2=A0 =C2=A0 =C2=A0 =C2=A0 <br>=
=C2=A0 =C2=A0 </span><span style=3D"color:#800">// Typical inserter functio=
n. </span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 </span><span style=
=3D"color:#606">CoutLn</span><span style=3D"color:#660">&amp;</span><span s=
tyle=3D"color:#000"> </span><span style=3D"color:#008">operator</span><span=
 style=3D"color:#660">&lt;&lt;(</span><span style=3D"color:#008">const</spa=
n><span style=3D"color:#000"> </span><span style=3D"color:#008">char</span>=
<span style=3D"color:#660">*</span><span style=3D"color:#000"> x</span><spa=
n style=3D"color:#660">)</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0=
 </span><span style=3D"color:#660">{</span><span style=3D"color:#000"><br>=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 cout </span><span style=3D"color:#660">&lt;&lt;=
</span><span style=3D"color:#000"> x</span><span style=3D"color:#660">;</sp=
an><span style=3D"color:#000"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span =
style=3D"color:#008">return</span><span style=3D"color:#000"> </span><span =
style=3D"color:#660">*</span><span style=3D"color:#008">this</span><span st=
yle=3D"color:#660">;</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 </s=
pan><span style=3D"color:#660">}</span><span style=3D"color:#000"><br>=C2=
=A0 =C2=A0 <br>=C2=A0 =C2=A0 </span><span style=3D"color:#800">// Terminato=
r operator. </span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 </span><spa=
n style=3D"color:#800">// Send a newline to the console at</span><span styl=
e=3D"color:#000"><br>=C2=A0 =C2=A0 </span><span style=3D"color:#800">// sta=
tement termination. </span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 </s=
pan><span style=3D"color:#008">void</span><span style=3D"color:#000"> =C2=
=A0</span><span style=3D"color:#008">operator</span><span style=3D"color:#6=
60">;()</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 </span><span sty=
le=3D"color:#660">{</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 =C2=
=A0 =C2=A0 cout </span><span style=3D"color:#660">&lt;&lt;</span><span styl=
e=3D"color:#000"> </span><span style=3D"color:#080">&#39;\n&#39;</span><spa=
n style=3D"color:#660">;</span><span style=3D"color:#000"> =C2=A0 =C2=A0 =
=C2=A0 =C2=A0<br>=C2=A0 =C2=A0 </span><span style=3D"color:#660">}</span><s=
pan style=3D"color:#000"><br>=C2=A0 =C2=A0 <br>=C2=A0 =C2=A0 </span><span s=
tyle=3D"color:#800">// Manipulator to ignore the next </span><span style=3D=
"color:#000"><br>=C2=A0 =C2=A0 </span><span style=3D"color:#800">// termina=
tor. </span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 </span><span style=
=3D"color:#008">const</span><span style=3D"color:#000"> </span><span style=
=3D"color:#008">static</span><span style=3D"color:#000"> </span><span style=
=3D"color:#008">struct</span><span style=3D"color:#000"> </span><span style=
=3D"color:#606">SkipNl</span><span style=3D"color:#000"> </span><span style=
=3D"color:#660">{}</span><span style=3D"color:#000"> skipnl</span><span sty=
le=3D"color:#660">;</span><span style=3D"color:#000"> <br>=C2=A0 =C2=A0 <br=
>=C2=A0 =C2=A0 </span><span style=3D"color:#800">// Return void on SkipNl, =
thus</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 </span><span style=
=3D"color:#800">// &quot;deactivating&quot; the subsequent </span><span sty=
le=3D"color:#000"><br>=C2=A0 =C2=A0 </span><span style=3D"color:#800">// te=
rminator operator. </span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 </sp=
an><span style=3D"color:#008">void</span><span style=3D"color:#000"> </span=
><span style=3D"color:#008">operator</span><span style=3D"color:#660">&lt;&=
lt;(</span><span style=3D"color:#008">const</span><span style=3D"color:#000=
"> </span><span style=3D"color:#606">SkipNl</span><span style=3D"color:#660=
">){}</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 <br></span><span s=
tyle=3D"color:#660">}</span><span style=3D"color:#000"> coutln</span><span =
style=3D"color:#660">;</span><span style=3D"color:#000"><br><br></span><spa=
n style=3D"color:#008">int</span><span style=3D"color:#000"> main</span><sp=
an style=3D"color:#660">()</span><span style=3D"color:#000"><br></span><spa=
n style=3D"color:#660">{</span><span style=3D"color:#000"> =C2=A0 =C2=A0<br=
>=C2=A0 =C2=A0 coutln </span><span style=3D"color:#660">&lt;&lt;</span><spa=
n style=3D"color:#000"> </span><span style=3D"color:#080">&quot;A&quot;</sp=
an><span style=3D"color:#000"> </span><span style=3D"color:#660">;</span><s=
pan style=3D"color:#000"> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 </span><span style=3D"color:#800">// Prints &quot;A\n&quot; <=
/span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 coutln </span><span styl=
e=3D"color:#660">&lt;&lt;</span><span style=3D"color:#000"> </span><span st=
yle=3D"color:#080">&quot;B&quot;</span><span style=3D"color:#000"> </span><=
span style=3D"color:#660">&lt;&lt;</span><span style=3D"color:#000"> </span=
><span style=3D"color:#606">CoutLn</span><span style=3D"color:#660">::</spa=
n><span style=3D"color:#000">skipnl </span><span style=3D"color:#660">;</sp=
an><span style=3D"color:#000"> </span><span style=3D"color:#800">// Prints =
&quot;B&quot; =C2=A0 =C2=A0</span><span style=3D"color:#000"><br></span><sp=
an style=3D"color:#660">}</span><span style=3D"color:#000"><br><br></span><=
/div></code></div><br><br></div></blockquote></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/5245fce2-adb0-4ca8-b9ac-f852f3025412%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/5245fce2-adb0-4ca8-b9ac-f852f3025412=
%40isocpp.org</a>.<br />

------=_Part_2865_2002104156.1468695679432--

------=_Part_2864_1581232004.1468695679431--

.


Author: Derek Ross <antiquarktv@gmail.com>
Date: Sat, 16 Jul 2016 13:01:44 -0700 (PDT)
Raw View
------=_Part_1141_492553140.1468699304672
Content-Type: multipart/alternative;
 boundary="----=_Part_1142_625456985.1468699304673"

------=_Part_1142_625456985.1468699304673
Content-Type: text/plain; charset=UTF-8

Thanks for the insight! It works as expected (see code below). I hereby
retract my request for the semicolon operator!

Cheers,
Derek

#include <iostream>
#include <sstream>
#include <iomanip>
using namespace std;

struct Syslog
{
    int level;
    ostringstream o;

    Syslog(int lev):level(lev){}

    template<class T>
    Syslog& operator<<(const T& x){
        o << x;
        return *this;
    }

    ~Syslog(){
        cout << "Calling ::syslog(" << level << ", \"" << o.str() << "\")"
<< endl;
    }

    operator bool (){
        return bool(o);
    }
};

int main(){
    Syslog(1) << "The number is 0x" << hex << 255;
    Syslog(2) << "The temp is " << 99.99;

    if(Syslog(3) << "Three")
    {
        Syslog(4) << "Four";
    }
    else
    {
        Syslog(5) << "Five";
    }
}


/* Prints out:

Calling ::syslog(1, "The number is 0xff")
Calling ::syslog(2, "The temp is 99.99")
Calling ::syslog(3, "Three")
Calling ::syslog(4, "Four")

*/




On Saturday, July 16, 2016 at 1:12:50 PM UTC-5, Wil Evers wrote:
>
>
>
> On Saturday, July 16, 2016 at 4:27:24 AM UTC+2, Derek Ross wrote:
>>
>> Maybe I should have waited until April 1st before posting this... but is
>> this a good idea? Seems to be OK to me.  If something like this existed
>> decades ago, I would have used it many many times by now (unless there's
>> some "gotcha" I missed)...
>>
>> Let's put a new operator into C++: the "terminator operator." It would
>> look like this: ';' (a semicolon). It would be a unary postfix operator
>> with a lower precedence than the comma operator.
>>
>> A class can overload the terminator operator by defining a member
>> function like:
>>
>>  void operator;(){
>>    ..etc..
>>  }
>>
>> The purpose of the terminator operator is to perform some action when a
>> sequence of operations reaches the statement terminator. If a terminator
>> operator isn't defined for an object, then nothing special happens.
>>
>
> C++ already has this; the destructors of temporaries are called at the
> 'end of full expression', that is, the semicolon.
>
> Wil
>
>
>

--
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/1669dfd0-705b-481b-b740-5f56ebfe19f6%40isocpp.org.

------=_Part_1142_625456985.1468699304673
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Thanks for the insight! It works as expected (see code bel=
ow). I hereby retract my request for the semicolon operator!<br><br>Cheers,=
<br>Derek<br><br><div class=3D"prettyprint" style=3D"background-color: rgb(=
250, 250, 250); border-color: rgb(187, 187, 187); border-style: solid; bord=
er-width: 1px; word-wrap: break-word;"><code class=3D"prettyprint"><div cla=
ss=3D"subprettyprint"><span style=3D"color: #800;" class=3D"styled-by-prett=
ify">#include</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> </span><span style=3D"color: #080;" class=3D"styled-by-prettify">&lt;io=
stream&gt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
<br></span><span style=3D"color: #800;" class=3D"styled-by-prettify">#inclu=
de</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span>=
<span style=3D"color: #080;" class=3D"styled-by-prettify">&lt;sstream&gt;</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><=
span style=3D"color: #800;" class=3D"styled-by-prettify">#include</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #080;" class=3D"styled-by-prettify">&lt;iomanip&gt;</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">using</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #00=
8;" class=3D"styled-by-prettify">namespace</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> std</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"><br><br></span><span style=3D"color: #008;" class=3D"style=
d-by-prettify">struct</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> </span><span style=3D"color: #606;" class=3D"styled-by-prettify=
">Syslog</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><b=
r></span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0=
 </span><span style=3D"color: #008;" class=3D"styled-by-prettify">int</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> level</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 ostringstr=
eam o</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=
=A0 <br>=C2=A0 =C2=A0 </span><span style=3D"color: #606;" class=3D"styled-b=
y-prettify">Syslog</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">(</span><span style=3D"color: #008;" class=3D"styled-by-prettify">i=
nt</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> lev</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">):</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify">level</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify">lev</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">){}</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 <br>=C2=A0 =C2=A0 </span><span s=
tyle=3D"color: #008;" class=3D"styled-by-prettify">template</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D"=
color: #008;" class=3D"styled-by-prettify">class</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> T</span><span style=3D"color: #660;"=
 class=3D"styled-by-prettify">&gt;</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><span style=3D"color: #606=
;" class=3D"styled-by-prettify">Syslog</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">&amp;</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"style=
d-by-prettify">operator</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">&lt;&lt;(</span><span style=3D"color: #008;" class=3D"styled-b=
y-prettify">const</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> T</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&=
amp;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> x</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">){</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=
=A0 =C2=A0 o </span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">&lt;&lt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> x</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=
=A0 =C2=A0 =C2=A0 </span><span style=3D"color: #008;" class=3D"styled-by-pr=
ettify">return</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">*</sp=
an><span style=3D"color: #008;" class=3D"styled-by-prettify">this</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">}</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 <br>=C2=A0=
 =C2=A0 </span><span style=3D"color: #660;" class=3D"styled-by-prettify">~<=
/span><span style=3D"color: #606;" class=3D"styled-by-prettify">Syslog</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">(){</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=
=A0 =C2=A0 cout </span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">&lt;&lt;</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> </span><span style=3D"color: #080;" class=3D"styled-by-prettify">&quot=
;Calling ::syslog(&quot;</span><span style=3D"color: #000;" class=3D"styled=
-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">&lt;&lt;</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> level </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
&lt;&lt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> <=
/span><span style=3D"color: #080;" class=3D"styled-by-prettify">&quot;, \&q=
uot;&quot;</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
 </span><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt;<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> o</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">.</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">str</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">()</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">&lt;&lt;</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #080;" class=3D"style=
d-by-prettify">&quot;\&quot;)&quot;</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">&lt;&lt;</span><span style=3D"color: #000;" class=3D"styled=
-by-prettify"> endl</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
<br>=C2=A0 =C2=A0 </span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">}</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><=
br>=C2=A0 =C2=A0 <br>=C2=A0 =C2=A0 </span><span style=3D"color: #008;" clas=
s=3D"styled-by-prettify">operator</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"style=
d-by-prettify">bool</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
(){</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=
=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color: #008;" class=3D"style=
d-by-prettify">return</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify=
">bool</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify">o</span><span=
 style=3D"color: #660;" class=3D"styled-by-prettify">);</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">}</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">};</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"><br><br></span><span style=3D"color: #008;=
" class=3D"styled-by-prettify">int</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> main</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">(){</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"><br>=C2=A0 =C2=A0 </span><span style=3D"color: #606;" class=3D"=
styled-by-prettify">Syslog</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">(</span><span style=3D"color: #066;" class=3D"styled-by-pre=
ttify">1</span><span style=3D"color: #660;" class=3D"styled-by-prettify">)<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt;</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D=
"color: #080;" class=3D"styled-by-prettify">&quot;The number is 0x&quot;</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span=
 style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt;</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> hex </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt;</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #066;" class=3D"styled-by-prettify">255</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><span style=3D"color: #606=
;" class=3D"styled-by-prettify">Syslog</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">(</span><span style=3D"color: #066;" class=3D"s=
tyled-by-prettify">2</span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">)</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt;=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><s=
pan style=3D"color: #080;" class=3D"styled-by-prettify">&quot;The temp is &=
quot;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt;</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span st=
yle=3D"color: #066;" class=3D"styled-by-prettify">99.99</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 <br>=C2=A0 =C2=A0 <=
/span><span style=3D"color: #008;" class=3D"styled-by-prettify">if</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=
=3D"color: #606;" class=3D"styled-by-prettify">Syslog</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #0=
66;" class=3D"styled-by-prettify">3</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">)</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">&lt;&lt;</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> </span><span style=3D"color: #080;" class=3D"styled-by-prettify">&quo=
t;Three&quot;</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">)</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=
=C2=A0 =C2=A0 </span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color: #606;" class=3D"st=
yled-by-prettify">Syslog</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">(</span><span style=3D"color: #066;" class=3D"styled-by-prett=
ify">4</span><span style=3D"color: #660;" class=3D"styled-by-prettify">)</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span=
 style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt;</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"c=
olor: #080;" class=3D"styled-by-prettify">&quot;Four&quot;</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">}</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">else</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </s=
pan><span style=3D"color: #606;" class=3D"styled-by-prettify">Syslog</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span sty=
le=3D"color: #066;" class=3D"styled-by-prettify">5</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">)</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">&lt;&lt;</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #080;" class=3D"style=
d-by-prettify">&quot;Five&quot;</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"><br>=C2=A0 =C2=A0 </span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">}</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> =C2=A0 =C2=A0<br></span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">}</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"><br><br><br></span><span style=3D"color: #800;" class=3D"styled-b=
y-prettify">/* Prints out:<br><br>Calling ::syslog(1, &quot;The number is 0=
xff&quot;)<br>Calling ::syslog(2, &quot;The temp is 99.99&quot;)<br>Calling=
 ::syslog(3, &quot;Three&quot;)<br>Calling ::syslog(4, &quot;Four&quot;)<br=
><br>*/</span></div></code></div><br><br><br><br>On Saturday, July 16, 2016=
 at 1:12:50 PM UTC-5, Wil Evers wrote:<blockquote class=3D"gmail_quote" sty=
le=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left=
: 1ex;"><div dir=3D"ltr"><br><br>On Saturday, July 16, 2016 at 4:27:24 AM U=
TC+2, Derek Ross wrote:<blockquote class=3D"gmail_quote" style=3D"margin:0;=
margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"=
ltr">Maybe I should have waited until April 1st before posting this... but =
is this a good idea? Seems to be OK to me.=C2=A0 If something like this exi=
sted decades ago, I would have used it many many times by now (unless there=
&#39;s some &quot;gotcha&quot; I missed)...<br><br>Let&#39;s put a new oper=
ator into C++: the &quot;terminator operator.&quot; It would look like this=
: &#39;;&#39; (a semicolon). It would be a unary postfix operator with a lo=
wer precedence than the comma operator. <br><br>A class can overload the te=
rminator operator by defining a member function like: <br><br><div style=3D=
"background-color:rgb(250,250,250);border-color:rgb(187,187,187);border-sty=
le:solid;border-width:1px;word-wrap:break-word"><code><div><span style=3D"c=
olor:#000">=C2=A0</span><span style=3D"color:#008">void</span><span style=
=3D"color:#000"> </span><span style=3D"color:#008">operator</span><span sty=
le=3D"color:#660">;(){</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0</=
span><span style=3D"color:#660">..</span><span style=3D"color:#000">etc</sp=
an><span style=3D"color:#660">..</span><span style=3D"color:#000"><br>=C2=
=A0</span><span style=3D"color:#660">}</span></div></code></div><br>The pur=
pose of the terminator operator is to perform some action when a sequence o=
f operations reaches the statement terminator. If a terminator operator isn=
&#39;t defined for an object, then nothing special happens. <br></div></blo=
ckquote><div><br>C++ already has this; the destructors of temporaries are c=
alled at the &#39;end of full expression&#39;, that is, the semicolon.<br><=
br>Wil<br>=C2=A0<br></div><div>=C2=A0</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&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/1669dfd0-705b-481b-b740-5f56ebfe19f6%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/1669dfd0-705b-481b-b740-5f56ebfe19f6=
%40isocpp.org</a>.<br />

------=_Part_1142_625456985.1468699304673--

------=_Part_1141_492553140.1468699304672--

.


Author: Tony V E <tvaneerd@gmail.com>
Date: Sat, 16 Jul 2016 18:32:46 -0400
Raw View
<html><head></head><body lang=3D"en-US" style=3D"background-color: rgb(255,=
 255, 255); line-height: initial;">                                        =
                                              <div style=3D"width: 100%; fo=
nt-size: initial; font-family: Calibri, 'Slate Pro', sans-serif, sans-serif=
; color: rgb(31, 73, 125); text-align: initial; background-color: rgb(255, =
255, 255);">Take a look at how Qt does it with QDebug etc.&nbsp;<span style=
=3D"font-family: Calibri, 'Slate Pro', sans-serif, sans-serif; font-size: i=
nitial; text-align: initial; line-height: initial;"></span></div>          =
                                                                           =
                                                <div style=3D"width: 100%; =
font-size: initial; font-family: Calibri, 'Slate Pro', sans-serif, sans-ser=
if; color: rgb(31, 73, 125); text-align: initial; background-color: rgb(255=
, 255, 255);"><br style=3D"display:initial"></div>                         =
                                                                           =
                                                                           =
                    <div style=3D"font-size: initial; font-family: Calibri,=
 'Slate Pro', sans-serif, sans-serif; color: rgb(31, 73, 125); text-align: =
initial; background-color: rgb(255, 255, 255);">Sent&nbsp;from&nbsp;my&nbsp=
;BlackBerry&nbsp;portable&nbsp;Babbage&nbsp;Device</div>                   =
                                                                           =
                                                                           =
         <table width=3D"100%" style=3D"background-color:white;border-spaci=
ng:0px;"> <tbody><tr><td colspan=3D"2" style=3D"font-size: initial; text-al=
ign: initial; background-color: rgb(255, 255, 255);">                      =
     <div style=3D"border-style: solid none none; border-top-color: rgb(181=
, 196, 223); border-top-width: 1pt; padding: 3pt 0in 0in; font-family: Taho=
ma, 'BB Alpha Sans', 'Slate Pro'; font-size: 10pt;">  <div><b>From: </b>Der=
ek Ross</div><div><b>Sent: </b>Saturday, July 16, 2016 4:01 PM</div><div><b=
>To: </b>ISO C++ Standard - Future Proposals</div><div><b>Reply To: </b>std=
-proposals@isocpp.org</div><div><b>Subject: </b>[std-proposals] Re: Let's o=
verload the semicolon!</div></div></td></tr></tbody></table><div style=3D"b=
order-style: solid none none; border-top-color: rgb(186, 188, 209); border-=
top-width: 1pt; font-size: initial; text-align: initial; background-color: =
rgb(255, 255, 255);"></div><br><div id=3D"_originalContent" style=3D""><div=
 dir=3D"ltr">Thanks for the insight! It works as expected (see code below).=
 I hereby retract my request for the semicolon operator!<br><br>Cheers,<br>=
Derek<br><br><div class=3D"prettyprint" style=3D"background-color: rgb(250,=
 250, 250); border-color: rgb(187, 187, 187); border-style: solid; border-w=
idth: 1px; word-wrap: break-word;"><code class=3D"prettyprint"><div class=
=3D"subprettyprint"><span style=3D"color: #800;" class=3D"styled-by-prettif=
y">#include</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> </span><span style=3D"color: #080;" class=3D"styled-by-prettify">&lt;iost=
ream&gt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><b=
r></span><span style=3D"color: #800;" class=3D"styled-by-prettify">#include=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><s=
pan style=3D"color: #080;" class=3D"styled-by-prettify">&lt;sstream&gt;</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><sp=
an style=3D"color: #800;" class=3D"styled-by-prettify">#include</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D=
"color: #080;" class=3D"styled-by-prettify">&lt;iomanip&gt;</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"=
color: #008;" class=3D"styled-by-prettify">using</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" =
class=3D"styled-by-prettify">namespace</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> std</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"><br><br></span><span style=3D"color: #008;" class=3D"styled-=
by-prettify">struct</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> </span><span style=3D"color: #606;" class=3D"styled-by-prettify">=
Syslog</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; <=
/span><span style=3D"color: #008;" class=3D"styled-by-prettify">int</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> level</span><span=
 style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; ostringstream=
 o</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp;=
 <br>&nbsp; &nbsp; </span><span style=3D"color: #606;" class=3D"styled-by-p=
rettify">Syslog</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">(</span><span style=3D"color: #008;" class=3D"styled-by-prettify">int<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> lev</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">):</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify">level</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify">lev</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">){}</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br>&nbsp; &nbsp; <br>&nbsp; &nbsp; </span><span st=
yle=3D"color: #008;" class=3D"styled-by-prettify">template</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D"c=
olor: #008;" class=3D"styled-by-prettify">class</span><span style=3D"color:=
 #000;" class=3D"styled-by-prettify"> T</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">&gt;</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br>&nbsp; &nbsp; </span><span style=3D"color: #606=
;" class=3D"styled-by-prettify">Syslog</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">&amp;</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"style=
d-by-prettify">operator</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">&lt;&lt;(</span><span style=3D"color: #008;" class=3D"styled-b=
y-prettify">const</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> T</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&=
amp;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> x</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">){</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; &nbs=
p; &nbsp; o </span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">&lt;&lt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
 x</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp;=
 &nbsp; &nbsp; </span><span style=3D"color: #008;" class=3D"styled-by-prett=
ify">return</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">*</span>=
<span style=3D"color: #008;" class=3D"styled-by-prettify">this</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; </span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">}</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; <br>&nbsp; &nbs=
p; </span><span style=3D"color: #660;" class=3D"styled-by-prettify">~</span=
><span style=3D"color: #606;" class=3D"styled-by-prettify">Syslog</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">(){</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; &nbsp; &n=
bsp; cout </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
&lt;&lt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> <=
/span><span style=3D"color: #080;" class=3D"styled-by-prettify">"Calling ::=
syslog("</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> <=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt;</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> level </span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt;</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span styl=
e=3D"color: #080;" class=3D"styled-by-prettify">", \""</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">&lt;&lt;</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> o</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">.</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify">str</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">()</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt;=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><s=
pan style=3D"color: #080;" class=3D"styled-by-prettify">"\")"</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">&lt;&lt;</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> endl</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"><br>&nbsp; &nbsp; </span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">}</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"><br>&nbsp; &nbsp; <br>&nbsp; &nbsp; </span><span s=
tyle=3D"color: #008;" class=3D"styled-by-prettify">operator</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"col=
or: #008;" class=3D"styled-by-prettify">bool</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">(){</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style=3D"col=
or: #008;" class=3D"styled-by-prettify">return</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" cl=
ass=3D"styled-by-prettify">bool</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">(</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify">o</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">);</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&=
nbsp; &nbsp; </span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">}</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">};</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"><br><br></span><span=
 style=3D"color: #008;" class=3D"styled-by-prettify">int</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> main</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">(){</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; </span><span style=3D"=
color: #606;" class=3D"styled-by-prettify">Syslog</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #066;"=
 class=3D"styled-by-prettify">1</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">)</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">&lt;&lt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> </span><span style=3D"color: #080;" class=3D"styled-by-prettify">"The num=
ber is 0x"</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
 </span><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt;<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> hex </span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt;</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span styl=
e=3D"color: #066;" class=3D"styled-by-prettify">255</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; </span><span style=3D"col=
or: #606;" class=3D"styled-by-prettify">Syslog</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #066;" cl=
ass=3D"styled-by-prettify">2</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">)</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
&lt;&lt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> <=
/span><span style=3D"color: #080;" class=3D"styled-by-prettify">"The temp i=
s "</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt;</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span styl=
e=3D"color: #066;" class=3D"styled-by-prettify">99.99</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; <br>&nbsp; &nbsp; </spa=
n><span style=3D"color: #008;" class=3D"styled-by-prettify">if</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"=
color: #606;" class=3D"styled-by-prettify">Syslog</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #066;"=
 class=3D"styled-by-prettify">3</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">)</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">&lt;&lt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> </span><span style=3D"color: #080;" class=3D"styled-by-prettify">"Three"<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">)</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; </=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; &nb=
sp; &nbsp; </span><span style=3D"color: #606;" class=3D"styled-by-prettify"=
>Syslog</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</=
span><span style=3D"color: #066;" class=3D"styled-by-prettify">4</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">)</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">&lt;&lt;</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #080;" cl=
ass=3D"styled-by-prettify">"Four"</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"><br>&nbsp; &nbsp; </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">}</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"><br>&nbsp; &nbsp; </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">else</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"><br>&nbsp; &nbsp; </span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style=3D"colo=
r: #606;" class=3D"styled-by-prettify">Syslog</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #066;" cla=
ss=3D"styled-by-prettify">5</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">)</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">&=
lt;&lt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </=
span><span style=3D"color: #080;" class=3D"styled-by-prettify">"Five"</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; </span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">}</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"> &nbsp; &nbsp;<br></span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">}</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"><br><br><br></span><span st=
yle=3D"color: #800;" class=3D"styled-by-prettify">/* Prints out:<br><br>Cal=
ling ::syslog(1, "The number is 0xff")<br>Calling ::syslog(2, "The temp is =
99.99")<br>Calling ::syslog(3, "Three")<br>Calling ::syslog(4, "Four")<br><=
br>*/</span></div></code></div><br><br><br><br>On Saturday, July 16, 2016 a=
t 1:12:50 PM UTC-5, Wil Evers wrote:<blockquote class=3D"gmail_quote" style=
=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: =
1ex;"><div dir=3D"ltr"><br><br>On Saturday, July 16, 2016 at 4:27:24 AM UTC=
+2, Derek Ross wrote:<blockquote class=3D"gmail_quote" style=3D"margin:0;ma=
rgin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"lt=
r">Maybe I should have waited until April 1st before posting this... but is=
 this a good idea? Seems to be OK to me.&nbsp; If something like this exist=
ed decades ago, I would have used it many many times by now (unless there's=
 some "gotcha" I missed)...<br><br>Let's put a new operator into C++: the "=
terminator operator." It would look like this: ';' (a semicolon). It would =
be a unary postfix operator with a lower precedence than the comma operator=
.. <br><br>A class can overload the terminator operator by defining a member=
 function like: <br><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><span style=3D"color:#000">&nbsp;</span><span style=3D=
"color:#008">void</span><span style=3D"color:#000"> </span><span style=3D"c=
olor:#008">operator</span><span style=3D"color:#660">;(){</span><span style=
=3D"color:#000"><br>&nbsp; &nbsp;</span><span style=3D"color:#660">..</span=
><span style=3D"color:#000">etc</span><span style=3D"color:#660">..</span><=
span style=3D"color:#000"><br>&nbsp;</span><span style=3D"color:#660">}</sp=
an></div></code></div><br>The purpose of the terminator operator is to perf=
orm some action when a sequence of operations reaches the statement termina=
tor. If a terminator operator isn't defined for an object, then nothing spe=
cial happens. <br></div></blockquote><div><br>C++ already has this; the des=
tructors of temporaries are called at the 'end of full expression', that is=
, the semicolon.<br><br>Wil<br>&nbsp;<br></div><div>&nbsp;</div></div></blo=
ckquote></div>

<p></p>

-- <br>
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"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/1669dfd0-705b-481b-b740-5f56ebfe19f6%=
40isocpp.org?utm_medium=3Demail&amp;utm_source=3Dfooter">https://groups.goo=
gle.com/a/isocpp.org/d/msgid/std-proposals/1669dfd0-705b-481b-b740-5f56ebfe=
19f6%40isocpp.org</a>.<br>
<br><!--end of _originalContent --></div></body></html>

<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/20160716223246.4882510.11380.14224%40=
gmail.com?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.com=
/a/isocpp.org/d/msgid/std-proposals/20160716223246.4882510.11380.14224%40gm=
ail.com</a>.<br />

.


Author: szollosi.lorand@gmail.com
Date: Sun, 17 Jul 2016 10:07:26 -0700 (PDT)
Raw View
------=_Part_3402_1127268175.1468775247075
Content-Type: multipart/alternative;
 boundary="----=_Part_3403_1778240241.1468775247075"

------=_Part_3403_1778240241.1468775247075
Content-Type: text/plain; charset=UTF-8

Re: 'C++ already has this; the destructors of temporaries are called at the
'end of full expression', that is, the semicolon.'

Not when the temporary is bound to a const ref.

--
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/ecb68077-feea-471a-a1a8-23a3bcaab8de%40isocpp.org.

------=_Part_3403_1778240241.1468775247075
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Re: &#39;C++ already has this; the destructors of temporar=
ies are called at the &#39;end of full expression&#39;, that is, the semico=
lon.&#39;<br><br>Not when the temporary is bound to a const ref.<br></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/ecb68077-feea-471a-a1a8-23a3bcaab8de%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/ecb68077-feea-471a-a1a8-23a3bcaab8de=
%40isocpp.org</a>.<br />

------=_Part_3403_1778240241.1468775247075--

------=_Part_3402_1127268175.1468775247075--

.


Author: Thiago Macieira <thiago@macieira.org>
Date: Sun, 17 Jul 2016 10:13:15 -0700
Raw View
On domingo, 17 de julho de 2016 10:07:26 PDT szollosi.lorand@gmail.com wrote:
> Re: 'C++ already has this; the destructors of temporaries are called at the
> 'end of full expression', that is, the semicolon.'
>
> Not when the temporary is bound to a const ref.

Which is when the developer wants to prevent the destructor from running.

For example, QDebug automatically prints a newline, so you'll find code like:

{
 QDebug s = qDebug().nospace();
 s << "SomeClass(";
 if (condition)
  s << "condition";
 s << ')';
} // newline printed here

--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel Open Source Technology Center

--
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/244870873.sCJyL056AL%40tjmaciei-mobl1.

.