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
Guest
Sat Aug 30 15:15:44 2025
from
As
via
Telnet
Heisenberg
Sat Aug 30 11:56:48 2025
from
Kalgoorlie, Western Australia
via
Telnet
Heisenberg
Sun Aug 31 00:50:23 2025
from
Kalgoorlie, Western Australia
via
Telnet
Heisenberg
Mon Sep 1 19:00:29 2025
from
Kalgoorlie, Western Australia
via
Telnet
System Info
Sysop:
Tetrazocine
Location:
Melbourne, VIC, Australia
Users:
12
Nodes:
8 (
0
/
8
)
Uptime:
44:32:47
Calls:
173
Files:
21,502
Messages:
79,839