From Jason Turner
Watch on YouTube

Summary

This episode explores the various 'emplace' functions available in C++ standard containers and their purpose of constructing objects directly in-place to avoid unnecessary copies or moves. Jason covers emplace implementations in sequence containers (emplace_back, emplace_front), associative containers (emplace, try_emplace), and demonstrates emplace_hint which accepts an iterator hint for potential performance improvements. The episode includes benchmark results showing significant performance differences when using correct hints in different standard library implementations, with GCC's library showing up to 7x speedup with correct hints.

Resources

Tags