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:jwakely....@gmail.com>
Sent: Monday, November 15, 2021 03:05
To: unlvsur unlvsur<mailto:unlv...@live.com>
Cc: gcc@gcc.gnu.org<mailto:gcc@gcc.gnu.org>
Subject: Re: Can I provide a hint to gcc for return value optimization?


On Mon, 15 Nov 2021, 06:47 unlvsur unlvsur via Gcc, 
<gcc@gcc.gnu.org<mailto:gcc@gcc.gnu.org>> 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.




Reply via email to