Use struct defined by myseld as key of Map in C++
You can use struct or class defined by yourself as key of std::map of C++.
Here, how to use struct defined by myself as key of std::map is introduced.

Among keys need to be compagit rable to find specified file from map, because std::map stores data as binary tree.
So not only data but also comparison operator need to be defined for struct defined by myself.

Here, sample code which uses int and char[100] struct as key is introduced.
Of course, there is another implementation of comparison operator.

It is required that comparison operator need to be defined to be able to decide small or large clearly.
The author took a long time to debug, when the author wrote wrong code for comparison operator.
For example, comparison operator implemented as to return false when int key is 0 and in other case to return true, values couldn't be stored and plucked out.
Even if comparison operator is not implemented properly, first data can be stored and plucked out.
If behavior seems wrong when struct defined by yourself used as key of map, first, you should check process of comparison operator.
use_struct_as_key_of_map.cpp
#include<string.h>

#include<map>
#include<string>
#include<iostream>

/**
 * @struct intStringKey_t
 * @brief This strcut is int-string key for map
 */
struct intStringKey_t {
  int intKey;
  char stringKey[100];
  bool operator < (const intStringKey_t& rhs) const {
    if (intKey < rhs.intKey) {
      return true;
    }
    if (intKey > rhs.intKey) {
      return false;
    }
    if ((strcmp(stringKey, rhs.stringKey)) < 0) {
      return true;
    }
    if ((strcmp(stringKey, rhs.stringKey)) > 0) {
      return false;
    }
    return false;
  }
}; // intStringKey_t

int main(void) {
  // Create map
  std::map<intStringKey_t, std::string> sampleMap;

  // Create keys
  intStringKey_t key1 = {1, "first"};
  intStringKey_t key2 = {2, "second"};
  intStringKey_t key3 = {3, "third"};

  // Insert values with keys
  sampleMap.insert(std::map<intStringKey_t, std::string>::value_type(key1, "1stValue"));
  sampleMap.insert(std::map<intStringKey_t, std::string>::value_type(key2, "2ndValue"));
  sampleMap.insert(std::map<intStringKey_t, std::string>::value_type(key3, "3rdValue"));

  // Show all key and value
  std::map<intStringKey_t, std::string>::iterator it = sampleMap.begin();
  while(it != sampleMap.end()) {
    std::cout
      << (*it).first.intKey
      << ", "
      << (*it).first.stringKey
      << ": "
      << (*it).second
      << std::endl;
    ++it;
  }

  return 0;
}

      
Result
$ g++ use_struct_as_key_of_map.cpp -o use_struct_as_key_of_map.cpp
$ ./use_struct_as_key_of_map
1, first: 1stValue
2, second: 2ndValue
3, third: 3rdValue