Pop-Up Thingie
Sidebar
d0p3 BBS
Home
Forum
Files
Dark
Register
Log in
Username
Password
Sidebar
Forum
Fidonet
COMP.LANG.C++
RVO vs. TCO
From
Marcel Mueller
@3:633/280.2 to
All
on Tue Jun 10 01: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
--- MBSE BBS v1.1.1 (Linux-x86_64)
* Origin: MB-NET.NET for Open-News-Network e.V. (3:633/280.2@fidonet)
Who's Online
Recent Visitors
Hiro
Wed May 21 00:36:55 2025
from
Pennsylvania
via
Telnet
Hiro
Wed May 21 00:36:35 2025
from
Pennsylvania
via
Telnet
Guest
Wed Jun 4 14:17:37 2025
from
Sadf
via
Telnet
Guest
Wed Jun 4 14:05:02 2025
from
Lijhjkl
via
Telnet
System Info
Sysop:
Tetrazocine
Location:
Melbourne, VIC, Australia
Users:
8
Nodes:
8 (
0
/
8
)
Uptime:
98:27:33
Calls:
161
Files:
21,502
Messages:
78,486