Oh I mean copy elision.
std::string str;
do_something(str);
return str;
Something like this.
Or factory function:
std::string foo()
{
return factory(a.begin(),a.end());
}
Sometimes the first one does not guarantee to happen?
Sent from Mail<https://go.microsoft.com/fwlink/?LinkId=550986> for Windows
From: Jonathan Wakely<mailto:[email protected]>
Sent: Monday, November 15, 2021 03:05
To: unlvsur unlvsur<mailto:[email protected]>
Cc: [email protected]<mailto:[email protected]>
Subject: Re: Can I provide a hint to gcc for return value optimization?
On Mon, 15 Nov 2021, 06:47 unlvsur unlvsur via Gcc,
<[email protected]<mailto:[email protected]>> wrote:
I want give a hint to gcc that allows std::string to rvo. Is that possible? Any
attribute for doing that?
It's already allowed, and will be done automatically whenever it's possible.