220 31201 <79ea3493-66f4-4386-9210-f3a3b80e0f30@isocpp.org> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Victor Dyachenko <victor.dyachenko@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Re: operator<< for std::string
Date: Tue, 28 Feb 2017 02:40:01 -0800 (PST)
Lines: 144
Approved: news@gmane.org
Message-ID: <79ea3493-66f4-4386-9210-f3a3b80e0f30@isocpp.org>
References: <7552b5b4-e778-46a2-a6f8-fabca5b16dc4@isocpp.org>
 <75e1c827-a2af-4dfa-9426-dc5a00a0d408@isocpp.org> <c1f7a833-a8fa-48d7-96c2-1ffe8ae292fc@isocpp.org>
 <85aefeb5-3c83-47de-a91d-3aef22d6a1ec@isocpp.org> <5f77cec0-c0b3-4993-9c3e-318c7e985f7f@isocpp.org>
 <cc23a9d4-db7d-40d7-b462-bba1ce306b12@isocpp.org> <46ec3307-ecfe-493c-b260-f2a39578d5ba@isocpp.org>
 <73b06839-b51a-4cd9-8316-cb9b3250c157@isocpp.org>
 <CAA7U3HMkshMNnw=goKaOpTDfNjz8hBg4pNGQKCwSn=XBpHYhXg@mail.gmail.com>
 <c8d79c4a-9565-4254-afed-2c4c2a0143fb@isocpp.org>
 <210528a6-2a10-4e42-8227-6fa87258d161@isocpp.org>
 <df858b3e-ef57-4e31-b1f7-f5a2c0755c87@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_1077_530352560.1488278402038"
X-Trace: blaine.gmane.org 1488278406 8283 195.159.176.226 (28 Feb 2017 10:40:06 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Tue, 28 Feb 2017 10:40:06 +0000 (UTC)
Cc: olaf@join.cc
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBCJ4XEO5S4ERBAVH2XCQKGQEP7DCEPQ@isocpp.org Tue Feb 28 11:40:01 2017
Return-path: <std-proposals+bncBCJ4XEO5S4ERBAVH2XCQKGQEP7DCEPQ@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-yw0-f198.google.com ([209.85.161.198])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCJ4XEO5S4ERBAVH2XCQKGQEP7DCEPQ@isocpp.org>)
	id 1cifCJ-0001W8-BB
	for gclcip-std-proposals@m.gmane.org; Tue, 28 Feb 2017 11:39:59 +0100
Original-Received: by mail-yw0-f198.google.com with SMTP id 204sf16278092ywo.6
        for <gclcip-std-proposals@m.gmane.org>; Tue, 28 Feb 2017 02:40:04 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=date:from:to:cc:message-id:in-reply-to:references:subject
         :mime-version: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=Tl2H+Wwy+i47E092qownrtOnvlk9LGtDXQP9X73SP3g=;
        b=Nswn6rGL6M65ZifmckFSyup3dPqRp7i4gs8530c30t1sHgTbSjDrel0ypUZj4VhvPR
         vhx+qV/c857yyynWp7EF0wikxeTIRl34Jj/pgN0Ahh5aikc3zrb1EI+7wmHgqMa0EiiP
         /ZbeIMqHgNIsOrPlJkq6ylM8PUx5OhcmMoRADsuDDkmL1Trn3jRsRyI6teZWjASm6EK1
         MuLz5r1Sqi94AzPn4RrsJVlCWAhiFh2+bwS0SJjrRqvV4IfxXDoIVfZqbjiIPfVDCscr
         NhP8DPT6p5swV4KKCeXFzUv7Gm9goxEp3jGp0DbN7hm+93TgKOkO7R6Cqg8RerLh/FTJ
         YRZw==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20161025;
        h=date:from:to:cc:message-id:in-reply-to:references:subject
         :mime-version: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=Tl2H+Wwy+i47E092qownrtOnvlk9LGtDXQP9X73SP3g=;
        b=XCdgjerJ6J9KfAaeKI88WkXj2/rGQt76d+Rku82GKKSojPboltpfguF61/7oJSYlcf
         tunx/IXUU5DTSHZGX6kDTCzdzTNMW+jhHEbrwiOSGBuOlN4rQRTbNYDi2XO73nstTDZV
         rDpvybczYR8/ktVoY46x59Pql73XtPegLz1ViKDYsqwJq5Z/RmcoAMs1uxyNBIL7HLZG
         mIJt3xNilvNg/0a42g9BFXvdnEa1zSMArszSA53wedfb5QQu/trVeH1DGrSndayZa2Bu
         OXR2fZHJVbrI1M++aMvrzA+pR42l+RrFMVAXd3YEa4lVuyKTeATkeJfzDCZew5+rSID6
         IiHg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:date:from:to:cc:message-id:in-reply-to
         :references:subject:mime-version: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=Tl2H+Wwy+i47E092qownrtOnvlk9LGtDXQP9X73SP3g=;
        b=qV0k0y8NYWKFiyA/Jw+B1vyTc+bjlTh/47QQ4IlCBsZenyhkjYaLtaavkPt7/hY2wq
         iBcy3piBsH43LpYWZdE0dO3c8hjIM+kdM6uVRYs3bxpEgSKH2f8a3JwER/HXjEQzV1r+
         +nuIsycHYLPIQZ9ksNqKpFaeaAAVvfkK6Wdn0A7J1dk3GHAazs1PSllsFHAfeQltQUzX
         zCSRCe5AIvNljnLXsxdEQGaK8ZuT+l/zY4El3NWDf8zX9v6p6X8+MtyhbR7vocky/3Tz
         eDoYvC1tv/USypLmymT8EZYZG7uegF6f3yTyBxaNvyzH4/VKCQn2wSNKAR+1DTTn7Bxe
         Wy8A==
X-Gm-Message-State: AMke39n950o+5aEqRlcOEWQbVDHEX7UQQAKxmmnxgnMhhJxDnj5fs9VNc8Dt5V76cM+4SQ==
X-Received: by 10.129.62.40 with SMTP id l40mr453828ywa.67.1488278403491;
        Tue, 28 Feb 2017 02:40:03 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.157.42.168 with SMTP id e37ls698259otb.13.gmail; Tue, 28 Feb
 2017 02:40:02 -0800 (PST)
X-Received: by 10.157.32.161 with SMTP id x30mr62934ota.20.1488278402742;
        Tue, 28 Feb 2017 02:40:02 -0800 (PST)
In-Reply-To: <df858b3e-ef57-4e31-b1f7-f5a2c0755c87@isocpp.org>
X-Original-Sender: Victor.Dyachenko@gmail.com
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Google-Group-Id: 399137483710
List-Post: <https://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <https://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <https://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <https://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>,
 <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:31201
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/31201>

------=_Part_1077_530352560.1488278402038
Content-Type: multipart/alternative; 
	boundary="----=_Part_1078_787191150.1488278402038"

------=_Part_1078_787191150.1488278402038
Content-Type: text/plain; charset=UTF-8

On Tuesday, February 28, 2017 at 12:17:26 PM UTC+3, ol...@join.cc wrote:
>
>
>
> Op woensdag 22 februari 2017 08:35:52 UTC+1 schreef Victor Dyachenko:
>>
>>
>> result_t res = call(...);
>> if(failed(res)) throw myexception(string_buffer(32) << "Error: result is 
>> " << res);
>>
>> So I solved the problem more than 10 years ago for myself, but I think 
>> this would be useful for others too if was added to stdlib.
>>
>
> Can you bind a rvalue to a non-const reference like that?
> I love the syntax but I can't make it work.. 
>
If you mean operator<<, it is a class member (see above). But you can make 
it free function as well using rvalue refs:

std::string &operator<<(std::string &s, int n) { .... }
inline std::string &operator<<(std::string &&s, int n) { return s << n; }

-- 
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/79ea3493-66f4-4386-9210-f3a3b80e0f30%40isocpp.org.

------=_Part_1078_787191150.1488278402038
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On Tuesday, February 28, 2017 at 12:17:26 PM UTC+3, ol...@=
join.cc wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-l=
eft: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"=
><br><br>Op woensdag 22 februari 2017 08:35:52 UTC+1 schreef Victor Dyachen=
ko:<blockquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;bo=
rder-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div><br><div s=
tyle=3D"background-color:rgb(250,250,250);border-color:rgb(187,187,187);bor=
der-style:solid;border-width:1px"><code><div><span style=3D"color:#000">res=
ult_t res </span><span style=3D"color:#660">=3D</span><span style=3D"color:=
#000"> call</span><span style=3D"color:#660">(...);</span><span style=3D"co=
lor:#000"><br></span><span style=3D"color:#008">if</span><span style=3D"col=
or:#660">(</span><span style=3D"color:#000">failed</span><span style=3D"col=
or:#660">(</span><span style=3D"color:#000">res</span><span style=3D"color:=
#660">))</span><span style=3D"color:#000"> </span><span style=3D"color:#008=
">throw</span><span style=3D"color:#000"> myexception</span><span style=3D"=
color:#660">(</span><span style=3D"color:#000">string_buffer</span><span st=
yle=3D"color:#660">(</span><span style=3D"color:#066">32</span><span style=
=3D"color:#660">)</span><span style=3D"color:#000"> </span><span style=3D"c=
olor:#660">&lt;&lt;</span><span style=3D"color:#000"> </span><span style=3D=
"color:#080">&quot;Error: result is &quot;</span><span style=3D"color:#000"=
> </span><span style=3D"color:#660">&lt;&lt;</span><span style=3D"color:#00=
0"> res</span><span style=3D"color:#660">);</span><span style=3D"color:#000=
"><br></span></div></code></div><br>So I solved the problem more than 10 ye=
ars ago for myself, but I think this would be useful for others too if was =
added to stdlib.<br></div></div></blockquote><div><br></div><div>Can you bi=
nd a rvalue to a non-const reference like that?</div><div>I love the syntax=
 but I can&#39;t make it work..=C2=A0</div></div></blockquote><div>If you m=
ean operator&lt;&lt;, it is a class member (see above). But you can make it=
 free function as well using rvalue refs:<br><br><div style=3D"background-c=
olor: rgb(250, 250, 250); border-color: rgb(187, 187, 187); border-style: s=
olid; border-width: 1px; overflow-wrap: break-word;" class=3D"prettyprint">=
<code class=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify">std</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">::</span><span style=3D"color: #008;" cla=
ss=3D"styled-by-prettify">string</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">&amp;</span><span style=3D"color: #008;" class=3D"styled-by-=
prettify">operator</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">&lt;&lt;(</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify">std</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
::</span><span style=3D"color: #008;" class=3D"styled-by-prettify">string</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">&amp;</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify">s</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: #008;" class=
=3D"styled-by-prettify">int</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> n</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">{</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">....</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">}</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br></span><span style=3D"color: #008;" class=3D"st=
yled-by-prettify">inline</span><span style=3D"color: #000;" class=3D"styled=
-by-prettify"> std</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">::</span><span style=3D"color: #008;" class=3D"styled-by-prettify">=
string</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">&amp;</span><=
span style=3D"color: #008;" class=3D"styled-by-prettify">operator</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt;(</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify">std</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">::</span><span style=3D"colo=
r: #008;" class=3D"styled-by-prettify">string</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">&amp;&amp;</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify">s</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: #008;" class=3D"styled-by-prettify">i=
nt</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> n</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">)</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">{</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">return</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> s </span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">&lt;&lt;</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> n</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">}</span></div><=
/code></div><br></div></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&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/79ea3493-66f4-4386-9210-f3a3b80e0f30%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/79ea3493-66f4-4386-9210-f3a3b80e0f30=
%40isocpp.org</a>.<br />

------=_Part_1078_787191150.1488278402038--

------=_Part_1077_530352560.1488278402038--

.
