Skip to content

Add Copy elisions#61

Draft
Magnus-Mage wants to merge 4 commits intoTCCPP:mainfrom
Magnus-Mage:add/copy_elisions
Draft

Add Copy elisions#61
Magnus-Mage wants to merge 4 commits intoTCCPP:mainfrom
Magnus-Mage:add/copy_elisions

Conversation

@Magnus-Mage
Copy link

Changes made:

* wiki/resources/cpp/: added Copy_elisions.md

Sign off: Magnus-Mage <>

Changes made:

	* wiki/resources/cpp/:
	added Copy_elisions.md

Sign off: Magnus-Mage <>
Copy link
Contributor

@ProfessionalMenace ProfessionalMenace left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change name from Copy_elisions.md to copy-elisions.md using

git mv Copy_elisions.md copy-elisions.md

Article not discoverable using a sidebar add

{
    text: "Copy Elision",
    link: "/resources/cpp/copy-elisions",
},

Changes made:

	* wiki/resources/cpp/Copy_elisions.md:
	Fixed the markdown issues.
	* wiki/resources/sidebar.ts
	added Copy_elisions under C++ resources

Signed off: Magnus-Mage <>
Copy link
Member

@jeremy-rifkin jeremy-rifkin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much for taking the time to put this article together! I've left some comments below, happy to chat about things more

Comment on lines 11 to 15
::: info
What This Means for You Copy elision is formally defined in the C++ standard under
[**copy elision**](https://en.cppreference.com/w/cpp/language/copy_elision). When it works, objects are constructed
directly where they're needed, skipping any intermediate copying steps entirely.
:::
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do this for the auto formatter

Suggested change
::: info
What This Means for You Copy elision is formally defined in the C++ standard under
[**copy elision**](https://en.cppreference.com/w/cpp/language/copy_elision). When it works, objects are constructed
directly where they're needed, skipping any intermediate copying steps entirely.
:::
::: info
What This Means for You Copy elision is formally defined in the C++ standard under
[**copy elision**](https://en.cppreference.com/w/cpp/language/copy_elision). When it works, objects are constructed
directly where they're needed, skipping any intermediate copying steps entirely.
:::

@@ -0,0 +1,733 @@
# Copy Elision
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rename the file to copy-elision.md


## A Brief History

Let's start with some context.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Best to avoid narration during wiki articles


Let's start with some context.

Back in 1988, compiler developers realized that programs were doing a lot of unnecessary copying when returning objects
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe include this history section as an aside somewhere? We'd like these wiki articles to be relatively focused.

Comment on lines 29 to 30
The introduction of move semantics in C++11 helped reduce copying costs, but copy elision remained even better because
it could eliminate operations entirely rather than just making them cheaper.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If going down the route of describing this stuff it would be worth noting that often copy elision and a move constructor invocation can be optimized the same thing, but copy elision bypasses move constructors all together which is helpful if the move constructor doesn't optimize away completely.

Foo moved
```

#### Unnamed Return Value Optimization (URVO)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be good to mention that this is also sometimes just called "RVO". The term URVO only appeared relatively recently and isn't very widely used.

image

I would recommend just removing the "RVO" header above, even though it makes sense to do it as you did I think the extra layer of hierarchy doesn't serve much purpose and the "RVO" header doesn't say much. This section can then be about Unnamed RVO.

Foo constructed
```

### Parameter Passing Elision
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is a common term, let's pick a better way to describe this

When you pass a temporary object or the result of a function call directly to a parameter, the compiler might construct
that object directly in the parameter's memory location rather than creating it elsewhere and then copying it.

### Exception Object Elision
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

Comment on lines 183 to 185
## Guaranteed vs Optional: Understanding the Difference

This is a crucial distinction that affects how confidently you can write your code.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
## Guaranteed vs Optional: Understanding the Difference
This is a crucial distinction that affects how confidently you can write your code.

@jeremy-rifkin jeremy-rifkin marked this pull request as draft January 27, 2026 03:13
@jeremy-rifkin
Copy link
Member

Marking as draft for now, please mark as ready once changes have been incorporated

Magnus-Mage and others added 2 commits February 8, 2026 15:49
Co-authored-by: Jeremy Rifkin <51220084+jeremy-rifkin@users.noreply.github.com>
- Rename Copy_elisions.md to copy-elision.md
- Remove unnecessary RVO hierarchy
- Condense history section into collapsible aside
- Remove narration and conversational elements
- Changed Headers for parameter and exception sections
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants