Skip to main content

Posts tagged with "c++"

View all tags

C++'s std::map and using strings as keys

Recently, I was working on some C++ code, using std::maps to map setting names (as strings) to their configured values (also as strings). Initially, all the key names were either specified using string literals, or variables assigned to literals, and it worked fine. Then I tried to access mappings using strings loaded from a drive at runtime as keys, but it was accessing different values than expected. This post will explain what happened, and how to resolve it!