hkaiser changed the topic of #ste||ar to: STE||AR: Systems Technology, Emergent Parallelism, and Algorithm Research | stellar-group.org | HPX: A cure for performance impaired parallel applications | github.com/STEllAR-GROUP/hpx | This channel is logged: irclog.cct.lsu.edu
Yorlik_ has joined #ste||ar
Yorlik__ has quit [Ping timeout: 252 seconds]
K-ballo has quit [Remote host closed the connection]
K-ballo1 has joined #ste||ar
K-ballo1 is now known as K-ballo
tufei has quit [Remote host closed the connection]
tufei has joined #ste||ar
K-ballo has quit [Ping timeout: 240 seconds]
K-ballo has joined #ste||ar
PranjalMittal[m] has quit [Quit: You have been kicked for being idle]
K-ballo has quit [Ping timeout: 240 seconds]
K-ballo has joined #ste||ar
sarkar_t[m] has quit [Quit: You have been kicked for being idle]
Yorlik_ is now known as Yorlik
HHN93 has joined #ste||ar
<HHN93>
hey, kind of a dumb question but what is the use of `return std::move(val)`?
<HHN93>
You can't return reference to a local variable so doesn't it cast val into a lvalue and copy it anyway?
<K-ballo>
casts to rvalue
<K-ballo>
depending on the source of val, the return type, and the c++ version the std::move may actually be a pessimization, disabling elision
<HHN93>
isn't return value optimisation was done whenever we return a local variable?
<K-ballo>
you're assuming val is local?
<HHN93>
yes
<K-ballo>
if the return type is an exact match then yes, locals were always elision candidates
<HHN93>
so std::move(val) disables epsilon copy in case we are returning an argument?
<K-ballo>
no, return std::move(val) always disables elision
<K-ballo>
always, assuming it's viable in the first place
<HHN93>
wait, disabling epsilon means we make a copy on return right?
<K-ballo>
or a move, if the thing is move constructible
<HHN93>
any reason we would want to disable return value optimisation?
<K-ballo>
no
<K-ballo>
also, this is technicaly *named* return value optimisation
<HHN93>
I just want to understand the reason we sometimes use return std::move(val) over simply return val
<K-ballo>
if val is a local, and the return type is an exact match, then it's just by mistake
<HHN93>
isn't it a bad thing that we are making another call to the copy (or move) constructor
<satacker[m]>
In constant expression and constant initialization, return value optimization (RVO) is guaranteed, however, named return value optimization (NRVO) is forbidden: