Joe Cecil

Beware map indexing in C++

Beware: If you index a C++ map with a key not in the map (e.g. map[key]), it won't raise an error — it'll just construct, insert and return a default value. If the value type has no default constructor, the program will segfault. This is

Joe Cecil © 2026