Topic: Suggestion: ostringstream::move_str()
Author: jgottman6@gmail.com
Date: Wed, 16 Oct 2013 18:46:18 -0700 (PDT)
Raw View
------=_Part_370_21974380.1381974378963
Content-Type: text/plain; charset=ISO-8859-1
A common use-case for std::ostringstream is to to do something like the
following:
std::string foo() {
std::ostringstream os;
/// write values to os
return os.str();
}
The method os.str() returns a string that is a copy of the collected state
of the ostringstream. It has to be, because it is possible to write more
values to os later. But in this function, it is not necessary to maintain
the state of the ostringstream, since it is about to be destructed anyway.
It would therefore be very nice to be able to return a version of
ostringstream::str() that steals the guts of the ostringstream, using
something like move semantics, and uses them to construct the returned
string more efficiently than by a copy Is this technically feasible?
Joe Gottman
--
---
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_370_21974380.1381974378963
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">A common use-case for std::ostringstream is to to do somet=
hing like the following:<br><br><div class=3D"prettyprint" style=3D"backgro=
und-color: rgb(250, 250, 250); border-color: rgb(187, 187, 187); border-sty=
le: solid; border-width: 1px; word-wrap: break-word;"><code class=3D"pretty=
print"><div class=3D"subprettyprint"><span 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"color: #008;" class=3D"styled-by-prett=
ify">string</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> foo</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">{</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"><br> std</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">::</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">ostringstream os</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: #800;" class=3D"styled-by-prettify">/// write values to os</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br> &=
nbsp;</span><span style=3D"color: #008;" class=3D"styled-by-prettify">retur=
n</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> os</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">.</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify">str</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 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>The method os.str() =
returns a string that is a copy of the collected state of the ostringstream=
.. It has to be, because it is possible to write more values to os lat=
er. But in this function, it is not necessary to maintain the state o=
f the ostringstream, since it is about to be destructed anyway. It wo=
uld therefore be very nice to be able to return a version of ostringstream:=
:str() that steals the guts of the ostringstream, using something like move=
semantics, and uses them to construct the returned string more efficiently=
than by a copy Is this technically feasible? <br><br>Joe Gottm=
an<br></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<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_370_21974380.1381974378963--
.
Author: Thiago Macieira <thiago@macieira.org>
Date: Wed, 16 Oct 2013 19:05:12 -0700
Raw View
On quarta-feira, 16 de outubro de 2013 18:46:18, jgottman6@gmail.com wrote:
> The method os.str() returns a string that is a copy of the collected state
> of the ostringstream. It has to be, because it is possible to write more
> values to os later. But in this function, it is not necessary to maintain
> the state of the ostringstream, since it is about to be destructed anyway.
> It would therefore be very nice to be able to return a version of
> ostringstream::str() that steals the guts of the ostringstream, using
> something like move semantics, and uses them to construct the returned
> string more efficiently than by a copy Is this technically feasible?
>
> Joe Gottman
This was discussed in the past month.
The problem is that the standard does not require ostringstream to be actually
backed by a string. It might use different kinds of buffers, including multiple
ones. Therefore, it's not possible to mandate that it actually moves anything.
At best, we could add a way to potentially do it, but not guarantee that.
--
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
--
---
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/.
.
Author: "Billy O'Neal" <billy.oneal@gmail.com>
Date: Wed, 16 Oct 2013 19:38:04 -0700
Raw View
--089e0158a92e6e99da04e8e6b72a
Content-Type: text/plain; charset=ISO-8859-1
Is an implementation permitted to add an overload like this?
string*&&* str() *&&*
{
/* ... */
}
Billy O'Neal
https://github.com/BillyONeal/ <https://bitbucket.org/BillyONeal/>
http://stackoverflow.com/users/82320/billy-oneal
Malware Response Instructor - BleepingComputer.com
On Wed, Oct 16, 2013 at 7:05 PM, Thiago Macieira <thiago@macieira.org>wrote:
> On quarta-feira, 16 de outubro de 2013 18:46:18, jgottman6@gmail.comwrote:
> > The method os.str() returns a string that is a copy of the collected
> state
> > of the ostringstream. It has to be, because it is possible to write more
> > values to os later. But in this function, it is not necessary to
> maintain
> > the state of the ostringstream, since it is about to be destructed
> anyway.
> > It would therefore be very nice to be able to return a version of
> > ostringstream::str() that steals the guts of the ostringstream, using
> > something like move semantics, and uses them to construct the returned
> > string more efficiently than by a copy Is this technically feasible?
> >
> > Joe Gottman
>
> This was discussed in the past month.
>
> The problem is that the standard does not require ostringstream to be
> actually
> backed by a string. It might use different kinds of buffers, including
> multiple
> ones. Therefore, it's not possible to mandate that it actually moves
> anything.
>
> At best, we could add a way to potentially do it, but not guarantee that.
>
> --
> 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
>
> --
>
> ---
> 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/.
>
--
---
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/.
--089e0158a92e6e99da04e8e6b72a
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Is an implementation permitted to add an overload like thi=
s?<div><br></div><div>string<b>&&</b> str() <b>&&</b></div>=
<div>{</div><div>=A0 =A0 =A0/* ... */</div><div>}<br><div class=3D"gmail_ex=
tra"><br clear=3D"all">
<div><div dir=3D"ltr"><div>Billy O'Neal</div><div><a href=3D"https://bi=
tbucket.org/BillyONeal/" target=3D"_blank">https://github.com/BillyONeal/</=
a></div><div><a href=3D"http://stackoverflow.com/users/82320/billy-oneal" t=
arget=3D"_blank">http://stackoverflow.com/users/82320/billy-oneal</a></div>
<div>Malware Response Instructor - BleepingComputer.com</div></div></div>
<br><br><div class=3D"gmail_quote">On Wed, Oct 16, 2013 at 7:05 PM, Thiago =
Macieira <span dir=3D"ltr"><<a href=3D"mailto:thiago@macieira.org" targe=
t=3D"_blank">thiago@macieira.org</a>></span> wrote:<br><blockquote class=
=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padd=
ing-left:1ex">
On quarta-feira, 16 de outubro de 2013 18:46:18, <a href=3D"mailto:jgottman=
6@gmail.com">jgottman6@gmail.com</a> wrote:<br>
> The method os.str() returns a string that is a copy of the collected s=
tate<br>
> of the ostringstream. =A0It has to be, because it is possible to write=
more<br>
> values to os later. =A0But in this function, it is not necessary to ma=
intain<br>
> the state of the ostringstream, since it is about to be destructed any=
way.<br>
> It would therefore be very nice to be able to return a version of<br>
> ostringstream::str() that steals the guts of the ostringstream, using<=
br>
> something like move semantics, and uses them to construct the returned=
<br>
> string more efficiently than by a copy =A0Is this technically feasible=
?<br>
><br>
> Joe Gottman<br>
<br>
This was discussed in the past month.<br>
<br>
The problem is that the standard does not require ostringstream to be actua=
lly<br>
backed by a string. It might use different kinds of buffers, including mult=
iple<br>
ones. Therefore, it's not possible to mandate that it actually moves an=
ything.<br>
<br>
At best, we could add a way to potentially do it, but not guarantee that.<b=
r>
<span class=3D"HOEnZb"><font color=3D"#888888"><br>
--<br>
Thiago Macieira - thiago (AT) <a href=3D"http://macieira.info" target=3D"_b=
lank">macieira.info</a> - thiago (AT) <a href=3D"http://kde.org" target=3D"=
_blank">kde.org</a><br>
=A0 =A0Software Architect - Intel Open Source Technology Center<br>
=A0 =A0 =A0 PGP/GPG: 0x6EF45358; fingerprint:<br>
=A0 =A0 =A0 E067 918B B660 DBD1 105C =A0966C 33F5 F005 6EF4 5358<br>
<br>
--<br>
<br>
---<br>
You received this message because you are subscribed to the Google Groups &=
quot;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%2Bunsubscribe@isocpp.org">std-propo=
sals+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/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
</font></span></blockquote></div><br></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" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<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 />
--089e0158a92e6e99da04e8e6b72a--
.
Author: Thiago Macieira <thiago@macieira.org>
Date: Wed, 16 Oct 2013 21:52:07 -0700
Raw View
On quarta-feira, 16 de outubro de 2013 19:38:04, Billy O'Neal wrote:
> Is an implementation permitted to add an overload like this?
>
> string*&&* str() *&&*
> {
> /* ... */
> }
[I'm assuming that the * indicate bold, not pointers]
In order to add str()&&, the existing method needs to become str() const & and
that's an ABI/API break.
--
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
--
---
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/.
.
Author: "Billy O'Neal" <billy.oneal@gmail.com>
Date: Wed, 16 Oct 2013 22:32:29 -0700
Raw View
--e89a8ff1ce023ad3e004e8e92796
Content-Type: text/plain; charset=ISO-8859-1
It renders as bold on my box :)
C++11 contained similar API/ABI breaks; e.g.
http://stackoverflow.com/questions/17002690/why-has-the-stdvectorresize-signature-been-changed-in-c11
Billy O'Neal
https://github.com/BillyONeal/ <https://bitbucket.org/BillyONeal/>
http://stackoverflow.com/users/82320/billy-oneal
Malware Response Instructor - BleepingComputer.com
On Wed, Oct 16, 2013 at 9:52 PM, Thiago Macieira <thiago@macieira.org>wrote:
> On quarta-feira, 16 de outubro de 2013 19:38:04, Billy O'Neal wrote:
> > Is an implementation permitted to add an overload like this?
> >
> > string*&&* str() *&&*
> > {
> > /* ... */
> > }
>
> [I'm assuming that the * indicate bold, not pointers]
>
> In order to add str()&&, the existing method needs to become str() const &
> and
> that's an ABI/API break.
>
> --
> 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
>
> --
>
> ---
> 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/.
>
--
---
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/.
--e89a8ff1ce023ad3e004e8e92796
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">It renders as bold on my box :)<div><br></div><div>C++11 c=
ontained similar API/ABI breaks; e.g.=A0<a href=3D"http://stackoverflow.com=
/questions/17002690/why-has-the-stdvectorresize-signature-been-changed-in-c=
11">http://stackoverflow.com/questions/17002690/why-has-the-stdvectorresize=
-signature-been-changed-in-c11</a></div>
</div><div class=3D"gmail_extra"><br clear=3D"all"><div><div dir=3D"ltr"><d=
iv>Billy O'Neal</div><div><a href=3D"https://bitbucket.org/BillyONeal/"=
target=3D"_blank">https://github.com/BillyONeal/</a></div><div><a href=3D"=
http://stackoverflow.com/users/82320/billy-oneal" target=3D"_blank">http://=
stackoverflow.com/users/82320/billy-oneal</a></div>
<div>Malware Response Instructor - BleepingComputer.com</div></div></div>
<br><br><div class=3D"gmail_quote">On Wed, Oct 16, 2013 at 9:52 PM, Thiago =
Macieira <span dir=3D"ltr"><<a href=3D"mailto:thiago@macieira.org" targe=
t=3D"_blank">thiago@macieira.org</a>></span> wrote:<br><blockquote class=
=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padd=
ing-left:1ex">
<div class=3D"im">On quarta-feira, 16 de outubro de 2013 19:38:04, Billy O&=
#39;Neal wrote:<br>
> Is an implementation permitted to add an overload like this?<br>
><br>
</div>> string*&&* str() *&&*<br>
> {<br>
> =A0 =A0 =A0/* ... */<br>
> }<br>
<br>
[I'm assuming that the * indicate bold, not pointers]<br>
<br>
In order to add str()&&, the existing method needs to become str() =
const & and<br>
that's an ABI/API break.<br>
<div class=3D"HOEnZb"><div class=3D"h5"><br>
--<br>
Thiago Macieira - thiago (AT) <a href=3D"http://macieira.info" target=3D"_b=
lank">macieira.info</a> - thiago (AT) <a href=3D"http://kde.org" target=3D"=
_blank">kde.org</a><br>
=A0 =A0Software Architect - Intel Open Source Technology Center<br>
=A0 =A0 =A0 PGP/GPG: 0x6EF45358; fingerprint:<br>
=A0 =A0 =A0 E067 918B B660 DBD1 105C =A0966C 33F5 F005 6EF4 5358<br>
<br>
--<br>
<br>
---<br>
You received this message because you are subscribed to the Google Groups &=
quot;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%2Bunsubscribe@isocpp.org">std-propo=
sals+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/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
</div></div></blockquote></div><br></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<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 />
--e89a8ff1ce023ad3e004e8e92796--
.
Author: "Billy O'Neal" <billy.oneal@gmail.com>
Date: Wed, 16 Oct 2013 22:49:05 -0700
Raw View
--001a11c336768cdf5604e8e962a6
Content-Type: text/plain; charset=ISO-8859-1
Actually, scratch that. Just realized the change in vector::resize isn't
detectable at all at the source level, while this change would be if
someone tried to create a member function pointer to str().
Billy O'Neal
https://github.com/BillyONeal/ <https://bitbucket.org/BillyONeal/>
http://stackoverflow.com/users/82320/billy-oneal
Malware Response Instructor - BleepingComputer.com
On Wed, Oct 16, 2013 at 10:32 PM, Billy O'Neal <billy.oneal@gmail.com>wrote:
> It renders as bold on my box :)
>
> C++11 contained similar API/ABI breaks; e.g.
> http://stackoverflow.com/questions/17002690/why-has-the-stdvectorresize-signature-been-changed-in-c11
>
> Billy O'Neal
> https://github.com/BillyONeal/ <https://bitbucket.org/BillyONeal/>
> http://stackoverflow.com/users/82320/billy-oneal
> Malware Response Instructor - BleepingComputer.com
>
>
> On Wed, Oct 16, 2013 at 9:52 PM, Thiago Macieira <thiago@macieira.org>wrote:
>
>> On quarta-feira, 16 de outubro de 2013 19:38:04, Billy O'Neal wrote:
>> > Is an implementation permitted to add an overload like this?
>> >
>> > string*&&* str() *&&*
>> > {
>> > /* ... */
>> > }
>>
>> [I'm assuming that the * indicate bold, not pointers]
>>
>> In order to add str()&&, the existing method needs to become str() const
>> & and
>> that's an ABI/API break.
>>
>> --
>> 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
>>
>> --
>>
>> ---
>> 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/.
>>
>
>
--
---
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/.
--001a11c336768cdf5604e8e962a6
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Actually, scratch that. Just realized the change in vector=
::resize isn't detectable at all at the source level, while this change=
would be if someone tried to create a member function pointer to str().</d=
iv>
<div class=3D"gmail_extra"><br clear=3D"all"><div><div dir=3D"ltr"><div>Bil=
ly O'Neal</div><div><a href=3D"https://bitbucket.org/BillyONeal/" targe=
t=3D"_blank">https://github.com/BillyONeal/</a></div><div><a href=3D"http:/=
/stackoverflow.com/users/82320/billy-oneal" target=3D"_blank">http://stacko=
verflow.com/users/82320/billy-oneal</a></div>
<div>Malware Response Instructor - BleepingComputer.com</div></div></div>
<br><br><div class=3D"gmail_quote">On Wed, Oct 16, 2013 at 10:32 PM, Billy =
O'Neal <span dir=3D"ltr"><<a href=3D"mailto:billy.oneal@gmail.com" t=
arget=3D"_blank">billy.oneal@gmail.com</a>></span> wrote:<br><blockquote=
class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc soli=
d;padding-left:1ex">
<div dir=3D"ltr">It renders as bold on my box :)<div><br></div><div>C++11 c=
ontained similar API/ABI breaks; e.g.=A0<a href=3D"http://stackoverflow.com=
/questions/17002690/why-has-the-stdvectorresize-signature-been-changed-in-c=
11" target=3D"_blank">http://stackoverflow.com/questions/17002690/why-has-t=
he-stdvectorresize-signature-been-changed-in-c11</a></div>
</div><div class=3D"gmail_extra"><div class=3D"im"><br clear=3D"all"><div><=
div dir=3D"ltr"><div>Billy O'Neal</div><div><a href=3D"https://bitbucke=
t.org/BillyONeal/" target=3D"_blank">https://github.com/BillyONeal/</a></di=
v><div>
<a href=3D"http://stackoverflow.com/users/82320/billy-oneal" target=3D"_bla=
nk">http://stackoverflow.com/users/82320/billy-oneal</a></div>
<div>Malware Response Instructor - BleepingComputer.com</div></div></div>
<br><br></div><div><div class=3D"h5"><div class=3D"gmail_quote">On Wed, Oct=
16, 2013 at 9:52 PM, Thiago Macieira <span dir=3D"ltr"><<a href=3D"mail=
to:thiago@macieira.org" target=3D"_blank">thiago@macieira.org</a>></span=
> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;padding=
-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-l=
eft-style:solid">
<div>On quarta-feira, 16 de outubro de 2013 19:38:04, Billy O'Neal wrot=
e:<br>
> Is an implementation permitted to add an overload like this?<br>
><br>
</div>> string*&&* str() *&&*<br>
> {<br>
> =A0 =A0 =A0/* ... */<br>
> }<br>
<br>
[I'm assuming that the * indicate bold, not pointers]<br>
<br>
In order to add str()&&, the existing method needs to become str() =
const & and<br>
that's an ABI/API break.<br>
<div><div><br>
--<br>
Thiago Macieira - thiago (AT) <a href=3D"http://macieira.info" target=3D"_b=
lank">macieira.info</a> - thiago (AT) <a href=3D"http://kde.org" target=3D"=
_blank">kde.org</a><br>
=A0 =A0Software Architect - Intel Open Source Technology Center<br>
=A0 =A0 =A0 PGP/GPG: 0x6EF45358; fingerprint:<br>
=A0 =A0 =A0 E067 918B B660 DBD1 105C =A0966C 33F5 F005 6EF4 5358<br>
<br>
--<br>
<br>
---<br>
You received this message because you are subscribed to the Google Groups &=
quot;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%2Bunsubscribe@isocpp.org" target=3D=
"_blank">std-proposals+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
</div></div></blockquote></div><br></div></div></div>
</blockquote></div><br></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<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 />
--001a11c336768cdf5604e8e962a6--
.
Author: =?ISO-8859-1?Q?Daniel_Kr=FCgler?= <daniel.kruegler@gmail.com>
Date: Thu, 17 Oct 2013 08:02:12 +0200
Raw View
2013/10/17 Billy O'Neal <billy.oneal@gmail.com>:
> Is an implementation permitted to add an overload like this?
>
> string&& str() &&
> {
> /* ... */
> }
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
http://cplusplus.github.io/LWG/lwg-active.html#2259
- Daniel
--
---
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/.
.
Author: Thiago Macieira <thiago@macieira.org>
Date: Wed, 16 Oct 2013 23:31:53 -0700
Raw View
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/.
.