fork download
  1. #include <algorithm>
  2. #include <iostream>
  3. #include <string>
  4. #include <map>
  5.  
  6. using UINT = unsigned int;
  7.  
  8. struct AsnObjectIdentifier
  9. {
  10. UINT idLength;
  11. UINT * ids;
  12. };
  13.  
  14. struct AsnObjectIdentifierComparator
  15. {
  16. bool operator()(const AsnObjectIdentifier& lhs, const AsnObjectIdentifier& rhs) const
  17. {
  18. return std::lexicographical_compare(lhs.ids, lhs.ids + lhs.idLength,
  19. rhs.ids, rhs.ids + rhs.idLength);
  20. }
  21. };
  22.  
  23. using MibMap = std::map<AsnObjectIdentifier, std::string, AsnObjectIdentifierComparator>;
  24.  
  25.  
  26. int main()
  27. {
  28. UINT expectedOID1ids[] = { 1, 3, 6, 1, 1, 1, 2, 1 };
  29. AsnObjectIdentifier expectedOID1 = { 8, expectedOID1ids };
  30. MibMap map{{expectedOID1, "present"}};
  31.  
  32. std::cout << map.size() << std::endl;
  33.  
  34. if (map.find(expectedOID1) == map.end()) {
  35. std::cout << "Not found" << std::endl;
  36. } else {
  37. std::cout << "Found" << std::endl;
  38. }
  39. }
Success #stdin #stdout 0s 4480KB
stdin
Standard input is empty
stdout
1
Found