4

Two tags appear to refer to the same technique in C++, the same exception to the 'as-if' rule:

114 Open Qs, 1 watcher

C++ copy-elision of return-values

47 Open Qs, 0 watcher

C++ copy-elision of named (thus non-temporary) return-values

(both tags: 24 Open Qs)

Let's synonymize them!


Though at least a third is 'related': 95 Open Qs, 1 watcher

C++ copy-elision of return-values.

This has synonym suggestions of (0 votes) and (2 votes).

(excluding 'double counting' the above represent a total of 235 distinct Qs, Open or not, based on a two-line SEDE query courtesy of modelbuilder42)

and possibly a fourth:

130 Open Qs, 3 watchers

Copy elision refers to an exception to the as-if rule allowing to omit copies

The topic/s are too niche for the data for Top Answerers to provide significant statistical data of relevance and unlikely the number of users available and empowered to achieve a synonym request through the 'standard' process.

0

3 Answers 3

8

All of these things are specific forms of one concept: Copy Elision.

Return value optimization is copy elision as applied to prvalue return expressions. Named return value optimization is copy elision as applied to named variables.

In order to understand how RVO works, you have to understand the basic concept of copy elision: that something which appears to be a copy/move doesn't have to be. Same goes for NRVO. So any experts on RVO are almost certainly experts on NRVO and on copy elision itself (since return values are one of the main beneficiaries of it).

The only way I can think of where a question about N/RVO would not also qualify as a question about copy elision is if it is asking whether certain compilers implement N/RVO in certain distinct instances. And even then, I'd still argue that it is fundamentally a question about copy elision.

So from my perspective, all of these should be synonyms of .


Note: I attempted to create such synonyms on , but they don't work. Apparently, this was attempted and rejected previously, so you can't attempt it again.

So the only remaining solution is to just go around and manually retag everything to .

1
  • 2
    The C++ language specification doesn't mention N/RVO at all, either the short acronym or spelled out. So they aren't distinct concepts from that perspective and they should all refer to the same idea of Copy Elision. Jul 21, 2018 at 4:42
3

Makes sense to merge them, but NVRO would be the wrong tag. There are really two types of Return Value Optimization, named and non-named. Using just the NVRO tag incorrectly suggests there's only one type. The justification of a better Wiki holds no weight, that can be trivially copied.

0
2

Related: as synonyms for the following are suggested , and (which with my down-vote got deleted)

I would have to disagree with the above and with MSalters's answer.

"Copy elision" is a form of optimization in C++ which states that under certain circumstances copy and move constructors can or must be omitted even if they have side effects. This is an exception to the as-if rule. One form of copy elision is known as "named return value optimization" - a.k.a NRVO. Another one is known as "return value optimization" - a.k.a RVO. There are also other forms of copy elision which don't involve returned values.

From a language point of view the distinction between RVO and NRVO becomes even more important in C++17 as RVO became mandatory allowing constructs which were previously illegal while NRVO is still optional.

Source: https://en.cppreference.com/w/cpp/language/copy_elision

So, in my view:

4
  • Are you sure it is actually useful to have separate tags for all the types of copy-elision allowed / mandated, instead of lumping them all under one tag together as you would have to handle all of them in a good answer anyway? Jul 20, 2018 at 21:16
  • @Deduplicator actually I am not sure. I thought of just having copy-elision. On the other hand the terms RVO and NRVO are thrown out there on the internet on C++ tutorials, articles etc so I fathom people will search for RVO and NRVO specifically.
    – bolov
    Jul 20, 2018 at 21:37
  • 1
    @pnuts: return-value-optimization exists, and is almost as popular as rvo (rvo has 114 questions at present, to the spelled out name's 105). named-return-value-optimization does not currently exist (and has less of a reason to exist, as unpronounceable four letter acronyms are less likely to overlap than three letter acronyms, where overlap is much more common). Jul 20, 2018 at 21:38
  • 1
    @pnuts Sorry, the post is nearly 4 years old now, and much changed in that time. Amongst others, I also hopefully learned a bit. Yes, the post is embarassingly weak, and the comment was part of thinking about how and if it could be refocused / redone / fixed. I had quite forgotten about it. Jul 20, 2018 at 22:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .