220 22025 <CAHK+-Fvzgi4sN8_3JQMxXb93uuka+KOYYDgjMN5RQfcxFJRvGw@mail.gmail.com> article
Path: news.gmane.org!not-for-mail
From: Sam Kellett <samkellett@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Re: New compound assignment operators.:)
Date: Tue, 27 Oct 2015 20:37:41 +0000
Lines: 97
Approved: news@gmane.org
Message-ID: <CAHK+-Fvzgi4sN8_3JQMxXb93uuka+KOYYDgjMN5RQfcxFJRvGw@mail.gmail.com>
References: <e0f0d04d-491f-43ba-90a8-858cdf308768@isocpp.org>
	<n0ols9$bom$1@ger.gmane.org>
	<6b98496b-ea50-4155-8560-4fd0d445a5c5@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary=001a11402550a8b87c05231c0c02
X-Trace: ger.gmane.org 1445978266 8391 80.91.229.3 (27 Oct 2015 20:37:46 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Tue, 27 Oct 2015 20:37:46 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDY6DWXBQIPRBFWBX6YQKGQEYIVF5EY@isocpp.org Tue Oct 27 21:37:44 2015
Return-path: <std-proposals+bncBDY6DWXBQIPRBFWBX6YQKGQEYIVF5EY@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-lf0-f70.google.com ([209.85.215.70])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBDY6DWXBQIPRBFWBX6YQKGQEYIVF5EY@isocpp.org>)
	id 1ZrB03-0001RB-Q1
	for gclcip-std-proposals@m.gmane.org; Tue, 27 Oct 2015 21:37:43 +0100
Original-Received: by lfu67 with SMTP id 67sf72834815lfu.2
        for <gclcip-std-proposals@m.gmane.org>; Tue, 27 Oct 2015 13:37:43 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:mime-version:in-reply-to:references:date
         :message-id:subject:from:to:content-type:x-original-sender
         :x-original-authentication-results:reply-to:precedence:mailing-list
         :list-id:x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=+XmVESY++1+YacjBYuIG7yG7jcTMKZAmbttf9alOxOI=;
        b=CWMMYIPKGQ21xdzMIC2iXqZ6oaQf89vBeKOZ+I061NV/XB6ruNpVLTgAdE1NZMuugb
         cxmCTfSfIVqIvTWuVmKcGssPYdqkDWLnDSvm33kkmYQEprAWY2W4sX8IDPta/x2xud+S
         Kv7CHKNOIP4AAgbRMKR6NfEjezmnSUWWKwe0QnRgNNbmyuu24CAjaL9tt3GYZW5ePtBB
         S2vPrvljjWb/69epOOlM+R0Vg966RDptAq7FVEOV+1C0S19D1V6958GiK85UlB1zE18r
         U/J0vtlhgLAMa+OIxRzFHsG+OqGd8m6cMtlfLievub/iA+NeM8RbphOKsq53zEpLjrW6
         ZkXg==
X-Gm-Message-State: ALoCoQnpxGkhD6sTLHp0IYd80xFy3wrIPbrXOqBz56rkwy2LfWc0x5G1kYSBCeV8sMmDcj9kHedA
X-Received: by 10.180.210.212 with SMTP id mw20mr5953855wic.3.1445978263329;
        Tue, 27 Oct 2015 13:37:43 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.25.159.2 with SMTP id i2ls283314lfe.56.gmail; Tue, 27 Oct 2015
 13:37:42 -0700 (PDT)
X-Received: by 10.112.149.5 with SMTP id tw5mr20936505lbb.50.1445978262095;
        Tue, 27 Oct 2015 13:37:42 -0700 (PDT)
Original-Received: from mail-lf0-x233.google.com (mail-lf0-x233.google.com. [2a00:1450:4010:c07::233])
        by mx.google.com with ESMTPS id g32si26091045lfi.87.2015.10.27.13.37.42
        for <std-proposals@isocpp.org>
        (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Tue, 27 Oct 2015 13:37:42 -0700 (PDT)
Received-SPF: pass (google.com: domain of samkellett@gmail.com designates 2a00:1450:4010:c07::233 as permitted sender) client-ip=2a00:1450:4010:c07::233;
Original-Received: by lffz202 with SMTP id z202so178768217lff.3
        for <std-proposals@isocpp.org>; Tue, 27 Oct 2015 13:37:42 -0700 (PDT)
X-Received: by 10.25.28.131 with SMTP id c125mr11205898lfc.99.1445978261991;
 Tue, 27 Oct 2015 13:37:41 -0700 (PDT)
Original-Received: by 10.114.245.165 with HTTP; Tue, 27 Oct 2015 13:37:41 -0700 (PDT)
In-Reply-To: <6b98496b-ea50-4155-8560-4fd0d445a5c5@isocpp.org>
X-Original-Sender: samkellett@gmail.com
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of samkellett@gmail.com designates 2a00:1450:4010:c07::233 as
 permitted sender) smtp.mailfrom=samkellett@gmail.com;       dkim=pass
 header.i=@gmail.com;       dmarc=pass (p=NONE dis=NONE) header.from=gmail.com
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Spam-Checked-In-Group: std-proposals@isocpp.org
X-Google-Group-Id: 399137483710
List-Post: <http://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <http://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <http://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:std-proposals+subscribe@isocpp.org>
List-Unsubscribe: <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>,
 <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:22025
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/22025>

--001a11402550a8b87c05231c0c02
Content-Type: text/plain; charset=UTF-8

On 27 October 2015 at 20:27, Vlad from Moscow <vlad.moscow@mail.ru> wrote:

> It is enough often  when I am writing a predicate for an algorithm I need
> to return the result of a comparison or other logical operator. But before
> to return the result I need to do some action with one of arguments or a
> captured cariable that takes part in the logical expression. So I have to
> introduce a boolean variable that to keep the result then do the action and
> only after that return the result.
>
> The idea came to my head when I was answering the following question at SO
> http://stackoverflow.com/questions/33375769/a-zero-indexed-array-given-an-equilibrium-index-of-this-array/33376721#33376721
>
> Instead of writing three statements in the if statement
>
>     for ( size_t i = 0; i < sizeof( a ) / sizeof( *a ); i++ )
>     {
>         right_sum -= a[i];
>         if ( left_sum == right_sum ) std::cout << i << ' ';
>         left_sum += a[i];
>     }
>
> I could write only one statement :)
>
>     for ( size_t i = 0; i < sizeof( a ) / sizeof( *a ); i++ )
>     {
>         if ( ( left_sum =+ a[i] ) == ( right_sum -= a[i] ) ) std::cout <<
> i << ' ';
>     }
>

what's wrong with writing three statements?

-- 

--- 
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

--001a11402550a8b87c05231c0c02
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On 27 October 2015 at 20:27, Vlad from Moscow <span dir=3D=
"ltr">&lt;<a href=3D"mailto:vlad.moscow@mail.ru" target=3D"_blank">vlad.mos=
cow@mail.ru</a>&gt;</span> wrote:<br><div class=3D"gmail_extra"><div class=
=3D"gmail_quote"><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8=
ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><span clas=
s=3D""></span><div>It is enough often=C2=A0=C2=A0when I am writing a predic=
ate for an algorithm I need to return the result of a comparison or other l=
ogical operator. But before to return the result I need to do some action w=
ith one of arguments or a captured cariable that takes part in the logical =
expression. So I have to introduce a boolean variable that to keep the resu=
lt then do the action and only after that return the result.</div><div><br>=
</div><div>The idea came to my head when I was answering the following ques=
tion at SO <a href=3D"http://stackoverflow.com/questions/33375769/a-zero-in=
dexed-array-given-an-equilibrium-index-of-this-array/33376721#33376721" tar=
get=3D"_blank">http://stackoverflow.com/questions/33375769/a-zero-indexed-a=
rray-given-an-equilibrium-index-of-this-array/33376721#33376721</a></div><d=
iv><br></div><div>Instead of writing three statements in the if statement</=
div><div><br></div><div><span>=C2=A0=C2=A0=C2=A0 for ( size_t i =3D 0; i &l=
t; sizeof( a ) / sizeof( *a ); i++ )<br>=C2=A0=C2=A0=C2=A0 {<br>=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 right_sum -=3D a[i];<br>=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0 if ( left_sum =3D=3D right_sum )=C2=A0std::cout=
 &lt;&lt; i &lt;&lt; &#39; &#39;;<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0 left_sum +=3D a[i];<br>=C2=A0=C2=A0=C2=A0 }<br></span></div><div>=C2=
=A0</div><div>I could write only one statement :)</div><div><br></div><div>=
=C2=A0=C2=A0=C2=A0 for ( size_t i =3D 0; i &lt; sizeof( a ) / sizeof( *a );=
 i++ )<br>=C2=A0=C2=A0=C2=A0 {<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0 if ( ( left_sum =3D+ a[i]=C2=A0)=C2=A0=3D=3D ( right_sum -=3D a[i] ) )=
=C2=A0std::cout &lt;&lt; i &lt;&lt; &#39; &#39;;<br>=C2=A0=C2=A0=C2=A0 }</d=
iv></div><div class=3D"HOEnZb"><div></div></div></blockquote><div><br></div=
><div>what&#39;s wrong with writing three statements?<br></div></div></div>=
</div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+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 />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

--001a11402550a8b87c05231c0c02--

.
