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

C++

321 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
[–] [email protected] 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.

[–] [email protected] 2 points 1 year ago* (last edited 1 year ago) (1 children)

I think you should never std::move return values. Afaik every modern compiler does NRVO and manually moving prevents it. And on the offchance you need to use a compiler that optimizes less, that one copy most likely is the least of the performance concerns.

[–] [email protected] 1 points 1 year ago

Afaik every modern compiler does NRVO and manually moving prevents it.

Yeah this is what bothers me. std::move could make things worse, but not if the alternative is a copy. But you're probably right that any self-respecting compiler nowadays would do NRVO.

load more comments (2 replies)