this post was submitted on 18 Jun 2023
8 points (100.0% liked)

C++

320 readers
1 users here now

A place for C++ programmers discuss articles and news about programming in C++ and the language itself

founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[–] tunetardis@lemmy.ca 2 points 1 year ago (4 children)

That's fascinating.

NVRO being optional annoys me. I'm always debating whether I should std::move the return value just in case, but if the compiler performs NVRO (which it probably does), this may be a pessimization right? Ugh.

[–] gracicot@discuss.tchncs.de 1 points 1 year ago (1 children)

I think compiler move return value by default, so even without NRVO you should never move a return value when it's a local non reference variable.

[–] tunetardis@lemmy.ca 1 points 1 year ago

Well the test3 example FTA gives a case where NRVO would not happen because of the conditional return value. Are you suggesting that you need not std::move even in this case?

load more comments (2 replies)