Pop-Up Thingie
Sidebar
>>> Magnum BBS <<<
Home
Forum
Files
Dark
Log in
Username
Password
Sidebar
Forum
Usenet
COMP.LANG.C++
RVO vs. TCO
From
Marcel Mueller
@21:1/5 to
All
on Mon Jun 9 17:16:12 2025
Hello,
does a tail call prevent return value optimization?
vector<XXX> func1();
vector<XXX> func2()
{
if (some_condition)
return func1();
vector<XXX> result;
// populate result
return result;
}
AFAIK RVO requires all paths of a function to return the same instance.
But can this also work with tail calls like func1()?
If not, the following work around could be preferred:
vector<XXX> func3()
{
vector<XXX> result;
if (some_condition)
result = func1(); // forces move
else
; // populate result
return result;
}
Marcel
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)
Who's Online
Recent Visitors
Ab Cadd
Sat Jun 6 15:42:53 2026
from
Sheboygan, Wi
via
Telnet
Centurion
Sat Jun 6 15:32:28 2026
from
Berea, Ohio
via
Telnet
Krenn
Sat Jun 6 11:38:56 2026
from
Sydney, Nsw
via
Telnet
Furryboy
Sat Jun 6 10:56:29 2026
from
Romania, Galati
via
SSH
Centurion
Fri Jun 5 22:28:01 2026
from
Berea, Ohio
via
Telnet
Ab Cadd
Fri Jun 5 17:52:51 2026
from
Sheboygan, Wi
via
Telnet
Gwylbert
Fri Jun 5 06:28:52 2026
from
Sydney, Nsw
via
Telnet
Centurion
Thu Jun 4 23:42:23 2026
from
Berea, Ohio
via
Telnet
System Info
Sysop:
Keyop
Location:
Huddersfield, West Yorkshire, UK
Users:
715
Nodes:
16 (
2
/
14
)
Uptime:
153:03:16
Calls:
12,091
Calls today:
4
Files:
15,000
Messages:
6,517,664