220 20681 <a116fdf2-266d-4e85-b0ab-b205bcc9ca70@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: Nicol Bolas <jmckesson@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Null -conditional and -coalescing operators
Date: Tue, 22 Sep 2015 19:53:07 -0700 (PDT)
Lines: 105
Approved: news@gmane.org
Message-ID: <a116fdf2-266d-4e85-b0ab-b205bcc9ca70@isocpp.org>
References: <4c3e2ee7-2159-4e93-a439-7d5c94c38c9c@isocpp.org>
 <d871b34e-cb96-4826-b52f-72fa0fdb104e@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_7076_99725498.1442976787356"
X-Trace: ger.gmane.org 1442976793 20876 80.91.229.3 (23 Sep 2015 02:53:13 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Wed, 23 Sep 2015 02:53:13 +0000 (UTC)
Cc: joewoodbury@gmail.com
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBCEKFTV6ZUMBBFFIRCYAKGQEFWHA6RI@isocpp.org Wed Sep 23 04:53:13 2015
Return-path: <std-proposals+bncBCEKFTV6ZUMBBFFIRCYAKGQEFWHA6RI@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-pd0-f198.google.com ([209.85.192.198])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBCEKFTV6ZUMBBFFIRCYAKGQEFWHA6RI@isocpp.org>)
	id 1ZeaBC-0002C9-IO
	for gclcip-std-proposals@m.gmane.org; Wed, 23 Sep 2015 04:53:10 +0200
Original-Received: by pdbpr5 with SMTP id pr5sf47658522pdb.2
        for <gclcip-std-proposals@m.gmane.org>; Tue, 22 Sep 2015 19:53:09 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=date:from:to:cc:message-id:in-reply-to:references:subject
         :mime-version:content-type:x-original-sender:reply-to:precedence
         :mailing-list:list-id:x-spam-checked-in-group:list-post:list-help
         :list-archive:list-subscribe:list-unsubscribe;
        bh=By3+vDxW0DCfD6gp2h5xGT/ZPx0QDxUsxr/rDsEfK6Q=;
        b=yePAO3oJU9ACucywGRsHGbBIlOhbjE8glD6sb8SizC4cPla+Ze0bm9JHCCWAWKf68t
         /UzmwAe0pkgDIFYfTrHwNpDHqCDAJwrsi2gcmqXtI2omDybq4dPozMTc//zuFVaVEE61
         +xioUkEGKKdiUN6Cp0VIO0UEl+ECzfoHpAeqglY2JnmNWueMRu0l3pjtk+Yfm2gEDk/e
         Nro1d9+3sKnlG7OJYF5Ra6SNID1xFnc1VTqK6thg0QH+ZlacgSWcE79xWMls7VZJ3zpv
         4ovb5A7Bp22Y+NoH9f01zXL4osJ/hT2dGNb4mNmQ8hR4Z/uxcIQxzsBJZ28Tknh1LbnG
         1A5w==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:date:from:to:cc:message-id:in-reply-to
         :references:subject:mime-version:content-type:x-original-sender
         :reply-to:precedence:mailing-list:list-id:x-spam-checked-in-group
         :list-post:list-help:list-archive:list-subscribe:list-unsubscribe;
        bh=By3+vDxW0DCfD6gp2h5xGT/ZPx0QDxUsxr/rDsEfK6Q=;
        b=VsuwLyPPPClMi/DhsvwpvLgVIiLfMEBqCDZtcFCPJsy8XZ9LfykyUXIjiCVW90XDlf
         vJtvHHvHD8Ao8OcM1ksBwcx1XssoF9mqEBKqyS8TVhzY+DsxoB6f9AFUT+DtZjPXHZgM
         fWW5PLWeJrVeFuZ8JSv1kzdGdfNMN7TIfO9Cb+JtqfSu1wcpIkhoCE5MvzhRVLsNeNWw
         K08WrTJ8Cltg3DuxpRuEna6BI0Ty9iY7Qaq/zXh21L2tpOkIGzk+UAnK+BtIjkl4oMy+
         CRcP8SuwYuBxkktB7Tm+MvMVp4No6PIijfQXPPTFWzHgSSxF71hPfuDcKfQJcnAb5v9Q
         OZYg==
X-Gm-Message-State: ALoCoQmYi7qqBEH4kP+MgPfNuHDmrBvQ3lUxm8gBxdETvVnQOJL+dhwKLk3HFbvktwTXl9Swbp7j
X-Received: by 10.66.197.136 with SMTP id iu8mr24981542pac.47.1442976789259;
        Tue, 22 Sep 2015 19:53:09 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.107.163.11 with SMTP id m11ls339266ioe.59.gmail; Tue, 22 Sep
 2015 19:53:08 -0700 (PDT)
X-Received: by 10.50.66.205 with SMTP id h13mr237655igt.10.1442976788412;
        Tue, 22 Sep 2015 19:53:08 -0700 (PDT)
In-Reply-To: <d871b34e-cb96-4826-b52f-72fa0fdb104e@isocpp.org>
X-Original-Sender: jmckesson@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:20681
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/20681>

------=_Part_7076_99725498.1442976787356
Content-Type: multipart/alternative; 
	boundary="----=_Part_7077_1075964204.1442976787356"

------=_Part_7077_1075964204.1442976787356
Content-Type: text/plain; charset=UTF-8



On Tuesday, September 22, 2015 at 8:34:20 PM UTC-4, joewo...@gmail.com 
wrote:
>
> Here in interesting example I just encountered:
>
> strLen is passed into a function along with pStr. After nullptr checks, 
> the following is done:
>
>             size_t tmpStrLen = wcslen(pStr);
>             if (strLen > tmpStrLen)
>                 strLen = tmpStrLen;
>
> Using the ?: operator, you could do:
>
>             strLen = wcslen(pStr) < strLen ?: strLen;
>
> Again, a trivial example, but one in actual code.
>

And this code would have made it much more clear what you were doing:

strLen = std::min(wcslen(pStr), strLen);

Also, I'm not sure how your suggestion is equivalent to the original. I see 
you have an expression that evaluates to bool. And I see you have an 
expression which will be evaluated if the boolean expression is true.

I don't see what the value of that expression will be if the boolean 
expression is false. So I'm not clear on exactly what your code means.

-- 

--- 
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/.

------=_Part_7077_1075964204.1442976787356
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><br>On Tuesday, September 22, 2015 at 8:34:20 PM UTC-4=
, joewo...@gmail.com wrote:<blockquote class=3D"gmail_quote" style=3D"margi=
n: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><di=
v dir=3D"ltr">Here in interesting example I just encountered:<br><br>strLen=
 is passed into a function along with pStr. After nullptr checks, the follo=
wing is done:<br><br>=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=
=A0 size_t tmpStrLen =3D wcslen(pStr);<br>=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=
=C2=A0 =C2=A0=C2=A0=C2=A0 if (strLen &gt; tmpStrLen)<br>=C2=A0=C2=A0=C2=A0 =
=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 strLen =3D tmpStrL=
en;<br><br>Using the ?: operator, you could do:<br><br>=C2=A0=C2=A0=C2=A0 =
=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 strLen =3D wcslen(pStr) &lt; strLen ?=
: strLen;<br><br>Again, a trivial example, but one in actual code.<br></div=
></blockquote><div dir=3D"ltr"><br>And this code would have made it much mo=
re clear what you were doing:<br><br><div class=3D"prettyprint" style=3D"ba=
ckground-color: rgb(250, 250, 250); border-color: rgb(187, 187, 187); borde=
r-style: solid; border-width: 1px; word-wrap: break-word;"><code class=3D"p=
rettyprint"><div class=3D"subprettyprint"><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify">strLen </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> std</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">::</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y">min</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify">wcslen</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify">pStr</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">),</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> strLen</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">);</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br></span></div></code></div><br>Also, I&#39;m not=
 sure how your suggestion is equivalent to the original. I see you have an =
expression that evaluates to bool. And I see you have an expression which w=
ill be evaluated if the boolean expression is true.<br><br>I don&#39;t see =
what the value of that expression will be if the boolean expression is fals=
e. So I&#39;m not clear on exactly what your code means.<br></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 />

------=_Part_7077_1075964204.1442976787356--
------=_Part_7076_99725498.1442976787356--

.
