C++ || How To Make Map & Unordered Map Keys Case Insensitive Using C++

Print Friendly, PDF & Email

The following is a module with functions which demonstrates how to make map and unordered_map keys case insensitive using C++.


1. Case Insensitive – Map

The example below demonstrates how to make a map with a string key case insensitive.

To do this, the comparison function needs to be overridden.


2. Case Insensitive – Unordered Map

The example below demonstrates how to make an unordered map with a string key case insensitive.

To do this, the comparison and the hash function needs to be overridden.


3. Full Examples

Below is a full example demonstrating the concepts on this page.

QUICK NOTES:
The highlighted lines are sections of interest to look out for.

The code is heavily commented, so no further insight is necessary. If you have any questions, feel free to leave a comment below.

Was this article helpful?
👍 YesNo

2 Responses to C++ || How To Make Map & Unordered Map Keys Case Insensitive Using C++

  1. Avatar Christian Dyrnesli says:

    Very cool stuff! 🙂 Can I just use the code, or?

Leave a Reply