From Jason Turner
Watch on YouTube

Summary

In this episode, Jason discusses whether it's beneficial to use std::move with std::array. While an array itself cannot be moved (as it's a stack-based object), the key insight is that std::move will propagate to the array's contents, potentially moving individual elements. Jason demonstrates that moving an array of movable objects (like std::string) results in significantly smaller generated code compared to copying, as it avoids deep copies of each element. This is a practical example of looking beyond the container to consider the move semantics of the contained elements.

Resources

Tags