Conversation
Changes made: * wiki/resources/cpp/: added Copy_elisions.md Sign off: Magnus-Mage <>
ProfessionalMenace
left a comment
There was a problem hiding this comment.
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 <>
jeremy-rifkin
left a comment
There was a problem hiding this comment.
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
wiki/resources/cpp/Copy_elisions.md
Outdated
| ::: 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. | ||
| ::: |
There was a problem hiding this comment.
Do this for the auto formatter
| ::: 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 | |||
There was a problem hiding this comment.
Please rename the file to copy-elision.md
wiki/resources/cpp/Copy_elisions.md
Outdated
|
|
||
| ## A Brief History | ||
|
|
||
| Let's start with some context. |
There was a problem hiding this comment.
Best to avoid narration during wiki articles
wiki/resources/cpp/Copy_elisions.md
Outdated
|
|
||
| Let's start with some context. | ||
|
|
||
| Back in 1988, compiler developers realized that programs were doing a lot of unnecessary copying when returning objects |
There was a problem hiding this comment.
Maybe include this history section as an aside somewhere? We'd like these wiki articles to be relatively focused.
wiki/resources/cpp/Copy_elisions.md
Outdated
| 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. |
There was a problem hiding this comment.
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.
wiki/resources/cpp/Copy_elisions.md
Outdated
| Foo moved | ||
| ``` | ||
|
|
||
| #### Unnamed Return Value Optimization (URVO) |
There was a problem hiding this comment.
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.
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.
wiki/resources/cpp/Copy_elisions.md
Outdated
| Foo constructed | ||
| ``` | ||
|
|
||
| ### Parameter Passing Elision |
There was a problem hiding this comment.
I don't think this is a common term, let's pick a better way to describe this
wiki/resources/cpp/Copy_elisions.md
Outdated
| 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 |
wiki/resources/cpp/Copy_elisions.md
Outdated
| ## Guaranteed vs Optional: Understanding the Difference | ||
|
|
||
| This is a crucial distinction that affects how confidently you can write your code. |
There was a problem hiding this comment.
| ## Guaranteed vs Optional: Understanding the Difference | |
| This is a crucial distinction that affects how confidently you can write your code. |
|
Marking as draft for now, please mark as ready once changes have been incorporated |
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
Changes made:
Sign off: Magnus-Mage <>