220 7342 <8091853.8bdkahh1DX@tjmaciei-mobl2> article
Path: news.gmane.org!not-for-mail
From: Thiago Macieira <thiago@macieira.org>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Suggestion: ostringstream::move_str()
Date: Wed, 16 Oct 2013 23:31:53 -0700
Lines: 73
Approved: news@gmane.org
Message-ID: <8091853.8bdkahh1DX@tjmaciei-mobl2>
References: <8d70b552-2ec1-45e7-9afb-dee28d73438a@isocpp.org> <CAPBZbvxNoA-3idKarWwMv+NTeZXafQX2tpFfu7XWaqg0TnJ2yQ@mail.gmail.com> <CAGNvRgBME4BHjGfLY1iVfJ+xUF=cWmjx4T6hkKm78ijkCu2PZA@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: ger.gmane.org 1381991511 3545 80.91.229.3 (17 Oct 2013 06:31:51 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Thu, 17 Oct 2013 06:31:51 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCB4TK757YBRBW4I72JAKGQERVJCPDA@isocpp.org Thu Oct 17 08:31:57 2013
Return-path: <std-proposals+bncBCB4TK757YBRBW4I72JAKGQERVJCPDA@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-lb0-f199.google.com ([209.85.217.199])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBCB4TK757YBRBW4I72JAKGQERVJCPDA@isocpp.org>)
	id 1VWh7k-0002Kw-Qh
	for gclcip-std-proposals@m.gmane.org; Thu, 17 Oct 2013 08:31:56 +0200
Original-Received: by mail-lb0-f199.google.com with SMTP id z5sf2151511lbh.2
        for <gclcip-std-proposals@m.gmane.org>; Wed, 16 Oct 2013 23:31:56 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=from:to:subject:date:message-id:user-agent:in-reply-to:references
         :mime-version:x-original-sender:x-original-authentication-results
         :reply-to:precedence:mailing-list:list-id:list-post:list-help
         :list-archive:list-subscribe:list-unsubscribe
         :content-transfer-encoding:content-type;
        bh=8JQBBAGbXwuMBWyE4JwfRZjjCMAf4gMA2BkZENWrLHQ=;
        b=NH17nDABOFdWfdk0H1x3L9LVBR/kHEWo72mjJ76TSaCekm3e6RynUqhn5uA39FDYwD
         M1HARypcQXjlhuyVAlu/vwQr2v/XgkwOaCQeXTTYNRDHO0oTG1IUHHKOHw9cvnhui9ha
         9NIQB6yP76QESrpLMPP6fKyu0vcqpkpc4D1k4N3KanzlnuZ3fuROBGN3KkXa6IeL2OHZ
         AJvq+b7xgM6KCwxI8WmeqULhnpShlxpgEFKU0tD2vyJEKg7QGAAy13YTIf4NBCUU1Ffi
         FFmPj/RoDJ+qpRRZo8mGIYRTNuFEwqofmb88Sa7qGZm8FGNckSqsobGTPmaSGq8iWkEE
         v1rA==
X-Received: by 10.152.25.161 with SMTP id d1mr2415758lag.7.1381991516097;
        Wed, 16 Oct 2013 23:31:56 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.180.182.169 with SMTP id ef9ls360829wic.30.gmail; Wed, 16 Oct
 2013 23:31:55 -0700 (PDT)
X-Received: by 10.15.35.67 with SMTP id f43mr251890eev.100.1381991515320;
        Wed, 16 Oct 2013 23:31:55 -0700 (PDT)
Original-Received: from gondolin.macieira.info (gondolin.macieira.info. [2a01:4f8:d13:f81:21c:14ff:fe01:12a3])
        by mx.google.com with ESMTP id b42si64312047eem.342.1969.12.31.16.00.00;
        Wed, 16 Oct 2013 23:31:55 -0700 (PDT)
Received-SPF: pass (google.com: domain of thiago@macieira.org designates 2a01:4f8:d13:f81:21c:14ff:fe01:12a3 as permitted sender) client-ip=2a01:4f8:d13:f81:21c:14ff:fe01:12a3;
Original-Received: from tjmaciei-mobl2.localnet (unknown [IPv6:2a01:4f8:d13:f81:21c:14ff:fe01:12a3])
	by gondolin.macieira.info (Postfix) with ESMTPSA id BF60012C005
	for <std-proposals@isocpp.org>; Wed, 16 Oct 2013 23:31:54 -0700 (PDT)
User-Agent: KMail/4.12 pre (Linux/3.9.10-100+i915fix.fc17.x86_64; KDE/4.11.60; x86_64; git-8054221; 2013-08-01)
In-Reply-To: <CAGNvRgBME4BHjGfLY1iVfJ+xUF=cWmjx4T6hkKm78ijkCu2PZA@mail.gmail.com>
X-Original-Sender: thiago@macieira.org
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of thiago@macieira.org designates 2a01:4f8:d13:f81:21c:14ff:fe01:12a3
 as permitted sender) smtp.mail=thiago@macieira.org
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: <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: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:7342
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/7342>

On quinta-feira, 17 de outubro de 2013 08:02:12, Daniel Kr=FCgler wrote:
> Implementations have already great freedom to play around with member
> functions overloads as denoted by [member.functions] p2. The intention
> is to make above kind of addition possible, but the current wording
> has not been updated in regard to ref-qualified member functions yet,
> see the third bullet in
>=20
> http://cplusplus.github.io/LWG/lwg-active.html#2259

There are two important differences there.

First, the wording allows one to add overloads, to provide a function with=
=20
more parameters, provided they're defaulted, or to split a function with=20
default parameters into more than one. In order to add a ref qualifier=20
overload, however, it requires changing the existing members.

Second, and more importantly, the recommendation is a guideline for how one=
=20
can write an implementation. The discussion here would *require* all=20
implementations to modify their already-existing ABI.

That's *exactly* the problem I had last week when I tried to implement an=
=20
rvalue-non-const QString::toLatin1. The solution I came up with is not pret=
ty:
	https://codereview.qt-project.org/67728
	https://codereview.qt-project.org/68300

Instead, maybe we can solve this by adding a pair of non-const new members =
to=20
stringstream:

	/* note how implementors may choose to implement the following
	 * function as actually two */
	string reset(const string &newstring =3D string())
	{ string tmp =3D str(); str(newstring); return tmp; }

	string reset(string &&newstring)
	{ string tmp =3D str(); str(move(newstring)); return tmp; }

The wording in the spec should say that it returns the current string and=
=20
resets the buffer to the provided argument and that nothing more is require=
d.

Implementations that store an actual string inside the basic_stringbuf may=
=20
optimise by inserting move operations. They might look like this:

	string reset(const string &newstring =3D string())
	{ swap(newstring, _M_stringbuf._M_string); return newstring;}

	string reset(string &&newstring)
	{ swap(newstring, _M_stringbuf._M_string); return newstring;}

--=20
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel Open Source Technology Center
      PGP/GPG: 0x6EF45358; fingerprint:
      E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358

--=20

---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.

.
