From Jason Turner
Watch on YouTube

Summary

This episode compares the square bracket operator (map[key]) with the at() method (map.at(key)) for accessing std::map elements. Jason examines the differences in functionality, generated assembly code, and runtime performance between these two approaches. He demonstrates that at() generates significantly less assembly code and can be slightly faster because it only performs lookup operations, while operator[] must support element insertion for non-existent keys, making it more complex and non-const.

Resources

Tags