From Jason Turner
Watch on YouTube

Summary

This episode explains how emplace_back works in C++11 compared to push_back by demonstrating the difference in object construction and move operations. Jason shows that emplace_back constructs objects directly in place within the container, avoiding the temporary object creation and move operations that occur with push_back. Through a detailed example with instrumented constructors and destructors, he demonstrates how emplace_back is more efficient by eliminating unnecessary move operations.

Resources

Tags