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.
Related C++ Standard Sections
This episode covers topics found in these sections of the C++ standard:
-
[map]74% match -
[out.of.range]40% match