Flat map all the things

In an earlier commit, entity-manager gained required dependency
on std::flat_map.  This means that EM can only compile with gcc-15,
which the project only recently moved to.  Rather than move backwards,
port forward all uses of boost flat_map and flat_set to their std
equivalents.

Tested: entity-manager launches and enumerates devices on
gb200-obmc.

Change-Id: Id24803057711c60d5b00f436db80b27edbb756a3
Signed-off-by: Ed Tanous <etanous@nvidia.com>
diff --git a/src/entity_manager/dbus_interface.cpp b/src/entity_manager/dbus_interface.cpp
index d7169ce..e42d9cd 100644
--- a/src/entity_manager/dbus_interface.cpp
+++ b/src/entity_manager/dbus_interface.cpp
@@ -3,9 +3,9 @@
 #include "perform_probe.hpp"
 #include "utils.hpp"
 
-#include <boost/container/flat_map.hpp>
 #include <phosphor-logging/lg2.hpp>
 
+#include <flat_map>
 #include <fstream>
 #include <regex>
 #include <string>
@@ -249,7 +249,7 @@
         "AddObject",
         [&systemConfiguration, jsonPointerPath{std::string(jsonPointerPath)},
          path{std::string(path)}, board,
-         this](const boost::container::flat_map<std::string, JsonVariantType>&
+         this](const std::flat_map<std::string, JsonVariantType, std::less<>>&
                    data) {
             nlohmann::json::json_pointer ptr(jsonPointerPath);
             nlohmann::json& base = systemConfiguration[ptr];
diff --git a/src/entity_manager/dbus_interface.hpp b/src/entity_manager/dbus_interface.hpp
index 9c20d8f..babc854 100644
--- a/src/entity_manager/dbus_interface.hpp
+++ b/src/entity_manager/dbus_interface.hpp
@@ -8,6 +8,7 @@
 #include <sdbusplus/asio/connection.hpp>
 #include <sdbusplus/asio/object_server.hpp>
 
+#include <flat_map>
 #include <vector>
 
 namespace dbus_interface
diff --git a/src/entity_manager/devices.hpp b/src/entity_manager/devices.hpp
index a2bcffa..ed0f8dc 100644
--- a/src/entity_manager/devices.hpp
+++ b/src/entity_manager/devices.hpp
@@ -2,19 +2,11 @@
 // SPDX-FileCopyrightText: Copyright 2018 Intel Corporation
 
 #pragma once
-#include <boost/container/flat_map.hpp>
+#include <flat_map>
 
 namespace devices
 {
 
-struct CmpStr
-{
-    bool operator()(const char* a, const char* b) const
-    {
-        return std::strcmp(a, b) < 0;
-    }
-};
-
 // I2C device drivers may create a /hwmon subdirectory. For example the tmp75
 // driver creates a /sys/bus/i2c/devices/<busnum>-<i2caddr>/hwmon
 // directory. The sensor code relies on the presence of the /hwmon
@@ -50,7 +42,7 @@
     createsHWMon hasHWMonDir;
 };
 
-const boost::container::flat_map<const char*, ExportTemplate, CmpStr>
+const std::flat_map<std::string_view, ExportTemplate, std::less<>>
     exportTemplates{
         {{"EEPROM_24C01",
           ExportTemplate("24c01 $Address", "/sys/bus/i2c/devices/i2c-$Bus",
diff --git a/src/entity_manager/entity_manager.cpp b/src/entity_manager/entity_manager.cpp
index a3b4a72..6bf3c52 100644
--- a/src/entity_manager/entity_manager.cpp
+++ b/src/entity_manager/entity_manager.cpp
@@ -16,7 +16,6 @@
 #include <boost/asio/io_context.hpp>
 #include <boost/asio/post.hpp>
 #include <boost/asio/steady_timer.hpp>
-#include <boost/container/flat_map.hpp>
 #include <boost/container/flat_set.hpp>
 #include <boost/range/iterator_range.hpp>
 #include <nlohmann/json.hpp>
@@ -29,6 +28,7 @@
 #include <xyz/openbmc_project/Inventory/Item/common.hpp>
 
 #include <filesystem>
+#include <flat_map>
 #include <fstream>
 #include <functional>
 #include <map>
diff --git a/src/entity_manager/entity_manager.hpp b/src/entity_manager/entity_manager.hpp
index c21b94e..70f7a4f 100644
--- a/src/entity_manager/entity_manager.hpp
+++ b/src/entity_manager/entity_manager.hpp
@@ -8,11 +8,11 @@
 #include "power_status_monitor.hpp"
 #include "topology.hpp"
 
-#include <boost/container/flat_map.hpp>
 #include <nlohmann/json.hpp>
 #include <sdbusplus/asio/connection.hpp>
 #include <sdbusplus/asio/object_server.hpp>
 
+#include <flat_map>
 #include <string>
 
 class EntityManager
@@ -84,7 +84,7 @@
     boost::asio::steady_timer propertiesChangedTimer;
     size_t propertiesChangedInstance = 0;
 
-    boost::container::flat_map<std::string, sdbusplus::bus::match_t>
+    std::flat_map<std::string, sdbusplus::bus::match_t, std::less<>>
         dbusMatches;
 
     void startRemovedTimer(boost::asio::steady_timer& timer,
diff --git a/src/entity_manager/log_device_inventory.cpp b/src/entity_manager/log_device_inventory.cpp
index 9662c97..93cf156 100644
--- a/src/entity_manager/log_device_inventory.cpp
+++ b/src/entity_manager/log_device_inventory.cpp
@@ -2,10 +2,10 @@
 
 #include <systemd/sd-journal.h>
 
-#include <boost/container/flat_map.hpp>
 #include <nlohmann/json.hpp>
 #include <xyz/openbmc_project/Inventory/Decorator/Asset/common.hpp>
 
+#include <flat_map>
 #include <string>
 
 struct InvAddRemoveInfo
diff --git a/src/entity_manager/overlay.cpp b/src/entity_manager/overlay.cpp
index ce41bca..f289715 100644
--- a/src/entity_manager/overlay.cpp
+++ b/src/entity_manager/overlay.cpp
@@ -9,12 +9,12 @@
 
 #include <boost/asio/io_context.hpp>
 #include <boost/asio/steady_timer.hpp>
-#include <boost/container/flat_map.hpp>
 #include <boost/container/flat_set.hpp>
 #include <nlohmann/json.hpp>
 #include <phosphor-logging/lg2.hpp>
 
 #include <filesystem>
+#include <flat_map>
 #include <fstream>
 #include <iomanip>
 #include <regex>
diff --git a/src/entity_manager/perform_probe.cpp b/src/entity_manager/perform_probe.cpp
index e5b57eb..94d3d21 100644
--- a/src/entity_manager/perform_probe.cpp
+++ b/src/entity_manager/perform_probe.cpp
@@ -184,7 +184,7 @@
     if (ret && foundDevs.empty())
     {
         foundDevs.emplace_back(
-            boost::container::flat_map<std::string, DBusValueVariant>{},
+            std::flat_map<std::string, DBusValueVariant, std::less<>>{},
             std::string{});
     }
     if (matchOne && ret)
@@ -220,8 +220,7 @@
 
 FoundProbeTypeT findProbeType(const std::string& probe)
 {
-    static const boost::container::flat_map<const char*, probe_type_codes,
-                                            CmpStr>
+    static const std::flat_map<std::string_view, probe_type_codes, std::less<>>
         probeTypes{{{"FALSE", probe_type_codes::FALSE_T},
                     {"TRUE", probe_type_codes::TRUE_T},
                     {"AND", probe_type_codes::AND},
@@ -229,8 +228,8 @@
                     {"FOUND", probe_type_codes::FOUND},
                     {"MATCH_ONE", probe_type_codes::MATCH_ONE}}};
 
-    boost::container::flat_map<const char*, probe_type_codes,
-                               CmpStr>::const_iterator probeType;
+    std::flat_map<std::string_view, probe_type_codes,
+                  std::less<>>::const_iterator probeType;
     for (probeType = probeTypes.begin(); probeType != probeTypes.end();
          ++probeType)
     {
diff --git a/src/entity_manager/perform_probe.hpp b/src/entity_manager/perform_probe.hpp
index 69c5375..0fdf674 100644
--- a/src/entity_manager/perform_probe.hpp
+++ b/src/entity_manager/perform_probe.hpp
@@ -2,21 +2,13 @@
 
 #include "perform_scan.hpp"
 
-#include <boost/container/flat_map.hpp>
-
+#include <flat_map>
 #include <memory>
 #include <string>
 #include <vector>
 
 namespace probe
 {
-struct CmpStr
-{
-    bool operator()(const char* a, const char* b) const
-    {
-        return std::strcmp(a, b) < 0;
-    }
-};
 
 // underscore T for collison with dbus c api
 enum class probe_type_codes
diff --git a/src/entity_manager/perform_scan.cpp b/src/entity_manager/perform_scan.cpp
index 6ba362b..85eb723 100644
--- a/src/entity_manager/perform_scan.cpp
+++ b/src/entity_manager/perform_scan.cpp
@@ -7,11 +7,11 @@
 #include "utils.hpp"
 
 #include <boost/asio/steady_timer.hpp>
-#include <boost/container/flat_map.hpp>
-#include <boost/container/flat_set.hpp>
 #include <phosphor-logging/lg2.hpp>
 
 #include <charconv>
+#include <flat_map>
+#include <flat_set>
 
 using GetSubTreeType = std::vector<
     std::pair<std::string,
@@ -42,7 +42,8 @@
 
     scan->_em.systemBus->async_method_call(
         [instance, scan, probeVector, retries,
-         &io](boost::system::error_code& errc, const DBusInterface& resp) {
+         &io](boost::system::error_code& errc,
+              const DBusInterface& resp) mutable {
             if (errc)
             {
                 lg2::error("error calling getall on {BUSNAME} {PATH} {INTF}",
@@ -59,7 +60,8 @@
                 return;
             }
 
-            scan->dbusProbeObjects[instance.path][instance.interface] = resp;
+            scan->dbusProbeObjects[std::string(instance.path)]
+                                  [std::string(instance.interface)] = resp;
         },
         instance.busName, instance.path, "org.freedesktop.DBus.Properties",
         "GetAll", instance.interface);
@@ -97,7 +99,7 @@
 // for the paths that own the interfaces passed in.
 void findDbusObjects(
     std::vector<std::shared_ptr<probe::PerformProbe>>&& probeVector,
-    boost::container::flat_set<std::string>&& interfaces,
+    std::flat_set<std::string, std::less<>>&& interfaces,
     const std::shared_ptr<scan::PerformScan>& scan, boost::asio::io_context& io,
     size_t retries = 5)
 {
@@ -540,7 +542,7 @@
 
 void scan::PerformScan::run()
 {
-    boost::container::flat_set<std::string> dbusProbeInterfaces;
+    std::flat_set<std::string, std::less<>> dbusProbeInterfaces;
     std::vector<std::shared_ptr<probe::PerformProbe>> dbusProbePointers;
 
     for (auto it = _configurations.begin(); it != _configurations.end();)
diff --git a/src/entity_manager/perform_scan.hpp b/src/entity_manager/perform_scan.hpp
index 317177e..fc8382d 100644
--- a/src/entity_manager/perform_scan.hpp
+++ b/src/entity_manager/perform_scan.hpp
@@ -5,10 +5,10 @@
 
 #include <systemd/sd-journal.h>
 
-#include <boost/container/flat_map.hpp>
 #include <nlohmann/json.hpp>
 #include <sdbusplus/asio/object_server.hpp>
 
+#include <flat_map>
 #include <functional>
 #include <list>
 #include <vector>
diff --git a/src/entity_manager/utils.hpp b/src/entity_manager/utils.hpp
index 04aa992..a8bba16 100644
--- a/src/entity_manager/utils.hpp
+++ b/src/entity_manager/utils.hpp
@@ -1,15 +1,16 @@
 #pragma once
 
 #include <boost/asio/io_context.hpp>
-#include <boost/container/flat_map.hpp>
 #include <nlohmann/json.hpp>
 #include <sdbusplus/asio/connection.hpp>
 
+#include <flat_map>
+
 using DBusValueVariant =
     std::variant<std::string, int64_t, uint64_t, double, int32_t, uint32_t,
                  int16_t, uint16_t, uint8_t, bool, std::vector<uint8_t>>;
-using DBusInterface = boost::container::flat_map<std::string, DBusValueVariant>;
-using DBusObject = boost::container::flat_map<std::string, DBusInterface>;
+using DBusInterface = std::flat_map<std::string, DBusValueVariant, std::less<>>;
+using DBusObject = std::flat_map<std::string, DBusInterface, std::less<>>;
 
 constexpr const char* configurationOutDir = "/var/configuration/";
 constexpr const char* versionHashFile = "/var/configuration/version";