Take out array size for constexpr std::array
C++20 supports initializing array without size using std::to_array
Signed-off-by: Brandon Kim <brandonkim@google.com>
Change-Id: I7f955ddaf7c4368f364eae6ff401b0916f5cbe6f
diff --git a/src/ADCSensorMain.cpp b/src/ADCSensorMain.cpp
index eea2766..1fac7dd 100644
--- a/src/ADCSensorMain.cpp
+++ b/src/ADCSensorMain.cpp
@@ -40,8 +40,8 @@
namespace fs = std::filesystem;
-static constexpr std::array<const char*, 1> sensorTypes = {
- "xyz.openbmc_project.Configuration.ADC"};
+static constexpr auto sensorTypes{
+ std::to_array<const char*>({"xyz.openbmc_project.Configuration.ADC"})};
static std::regex inputRegex(R"(in(\d+)_input)");
static boost::container::flat_map<size_t, bool> cpuPresence;
diff --git a/src/CPUSensorMain.cpp b/src/CPUSensorMain.cpp
index 3d602bf..b344a6c 100644
--- a/src/CPUSensorMain.cpp
+++ b/src/CPUSensorMain.cpp
@@ -89,9 +89,9 @@
static constexpr const char* configPrefix =
"xyz.openbmc_project.Configuration.";
-static constexpr std::array<const char*, 1> sensorTypes = {"XeonCPU"};
-static constexpr std::array<const char*, 3> hiddenProps = {
- CPUSensor::labelTcontrol, "Tthrottle", "Tjmax"};
+static constexpr auto sensorTypes{std::to_array<const char*>({"XeonCPU"})};
+static constexpr auto hiddenProps{std::to_array<const char*>(
+ {CPUSensor::labelTcontrol, "Tthrottle", "Tjmax"})};
void detectCpuAsync(
boost::asio::deadline_timer& pingTimer,
diff --git a/src/ExitAirTempSensor.cpp b/src/ExitAirTempSensor.cpp
index fad0020..a36c183 100644
--- a/src/ExitAirTempSensor.cpp
+++ b/src/ExitAirTempSensor.cpp
@@ -57,8 +57,8 @@
static constexpr size_t minSystemCfm = 50;
-constexpr const std::array<const char*, 2> monitorIfaces = {exitAirIface,
- cfmIface};
+constexpr const auto monitorIfaces{
+ std::to_array<const char*>({exitAirIface, cfmIface})};
static std::vector<std::shared_ptr<CFMSensor>> cfmSensors;
@@ -547,8 +547,8 @@
void ExitAirTempSensor::setupMatches(void)
{
- constexpr const std::array<const char*, 2> matchTypes = {
- "power", inletTemperatureSensor};
+ constexpr const auto matchTypes{
+ std::to_array<const char*>({"power", inletTemperatureSensor})};
std::weak_ptr<ExitAirTempSensor> weakRef = weak_from_this();
for (const std::string type : matchTypes)
diff --git a/src/FanMain.cpp b/src/FanMain.cpp
index 9f1a21e..786498c 100644
--- a/src/FanMain.cpp
+++ b/src/FanMain.cpp
@@ -42,10 +42,10 @@
namespace fs = std::filesystem;
// The following two structures need to be consistent
-static constexpr std::array<const char*, 3> sensorTypes = {
- "xyz.openbmc_project.Configuration.AspeedFan",
- "xyz.openbmc_project.Configuration.I2CFan",
- "xyz.openbmc_project.Configuration.NuvotonFan"};
+static auto sensorTypes{std::to_array<const char*>(
+ {"xyz.openbmc_project.Configuration.AspeedFan",
+ "xyz.openbmc_project.Configuration.I2CFan",
+ "xyz.openbmc_project.Configuration.NuvotonFan"})};
enum FanTypes
{
diff --git a/src/HwmonTempMain.cpp b/src/HwmonTempMain.cpp
index 20af79d..7344b57 100644
--- a/src/HwmonTempMain.cpp
+++ b/src/HwmonTempMain.cpp
@@ -39,24 +39,24 @@
static constexpr float pollRateDefault = 0.5;
namespace fs = std::filesystem;
-static constexpr std::array<const char*, 17> sensorTypes = {
- "xyz.openbmc_project.Configuration.EMC1412",
- "xyz.openbmc_project.Configuration.EMC1413",
- "xyz.openbmc_project.Configuration.EMC1414",
- "xyz.openbmc_project.Configuration.MAX31725",
- "xyz.openbmc_project.Configuration.MAX31730",
- "xyz.openbmc_project.Configuration.MAX6581",
- "xyz.openbmc_project.Configuration.MAX6654",
- "xyz.openbmc_project.Configuration.NCT7802",
- "xyz.openbmc_project.Configuration.SBTSI",
- "xyz.openbmc_project.Configuration.LM95234",
- "xyz.openbmc_project.Configuration.TMP112",
- "xyz.openbmc_project.Configuration.TMP175",
- "xyz.openbmc_project.Configuration.TMP421",
- "xyz.openbmc_project.Configuration.TMP441",
- "xyz.openbmc_project.Configuration.LM75A",
- "xyz.openbmc_project.Configuration.TMP75",
- "xyz.openbmc_project.Configuration.W83773G"};
+static auto sensorTypes{
+ std::to_array<const char*>({"xyz.openbmc_project.Configuration.EMC1412",
+ "xyz.openbmc_project.Configuration.EMC1413",
+ "xyz.openbmc_project.Configuration.EMC1414",
+ "xyz.openbmc_project.Configuration.MAX31725",
+ "xyz.openbmc_project.Configuration.MAX31730",
+ "xyz.openbmc_project.Configuration.MAX6581",
+ "xyz.openbmc_project.Configuration.MAX6654",
+ "xyz.openbmc_project.Configuration.NCT7802",
+ "xyz.openbmc_project.Configuration.SBTSI",
+ "xyz.openbmc_project.Configuration.LM95234",
+ "xyz.openbmc_project.Configuration.TMP112",
+ "xyz.openbmc_project.Configuration.TMP175",
+ "xyz.openbmc_project.Configuration.TMP421",
+ "xyz.openbmc_project.Configuration.TMP441",
+ "xyz.openbmc_project.Configuration.LM75A",
+ "xyz.openbmc_project.Configuration.TMP75",
+ "xyz.openbmc_project.Configuration.W83773G"})};
void createSensors(
boost::asio::io_service& io, sdbusplus::asio::object_server& objectServer,
diff --git a/src/IntrusionSensorMain.cpp b/src/IntrusionSensorMain.cpp
index 85fe3e5..bed6675 100644
--- a/src/IntrusionSensorMain.cpp
+++ b/src/IntrusionSensorMain.cpp
@@ -47,7 +47,7 @@
static constexpr const char* sensorType =
"xyz.openbmc_project.Configuration.ChassisIntrusionSensor";
static constexpr const char* nicType = "xyz.openbmc_project.Configuration.NIC";
-static constexpr std::array<const char*, 1> nicTypes = {nicType};
+static constexpr auto nicTypes{std::to_array<const char*>({nicType})};
namespace fs = std::filesystem;
diff --git a/src/PSUSensorMain.cpp b/src/PSUSensorMain.cpp
index 779873e..4f7eb06 100644
--- a/src/PSUSensorMain.cpp
+++ b/src/PSUSensorMain.cpp
@@ -40,34 +40,34 @@
static constexpr bool debug = false;
-static constexpr std::array<const char*, 27> sensorTypes = {
- "xyz.openbmc_project.Configuration.ADM1266",
- "xyz.openbmc_project.Configuration.ADM1272",
- "xyz.openbmc_project.Configuration.ADM1275",
- "xyz.openbmc_project.Configuration.ADM1278",
- "xyz.openbmc_project.Configuration.DPS800",
- "xyz.openbmc_project.Configuration.INA219",
- "xyz.openbmc_project.Configuration.INA230",
- "xyz.openbmc_project.Configuration.IPSPS",
- "xyz.openbmc_project.Configuration.ISL68137",
- "xyz.openbmc_project.Configuration.ISL68220",
- "xyz.openbmc_project.Configuration.ISL68223",
- "xyz.openbmc_project.Configuration.ISL69243",
- "xyz.openbmc_project.Configuration.ISL69260",
- "xyz.openbmc_project.Configuration.LM25066",
- "xyz.openbmc_project.Configuration.MAX16601",
- "xyz.openbmc_project.Configuration.MAX20710",
- "xyz.openbmc_project.Configuration.MAX20730",
- "xyz.openbmc_project.Configuration.MAX20734",
- "xyz.openbmc_project.Configuration.MAX20796",
- "xyz.openbmc_project.Configuration.MAX34451",
- "xyz.openbmc_project.Configuration.pmbus",
- "xyz.openbmc_project.Configuration.PXE1610",
- "xyz.openbmc_project.Configuration.RAA228000",
- "xyz.openbmc_project.Configuration.RAA228228",
- "xyz.openbmc_project.Configuration.RAA229004",
- "xyz.openbmc_project.Configuration.TPS546D24",
- "xyz.openbmc_project.Configuration.XDPE12284"};
+static constexpr auto sensorTypes{std::to_array<const char*>(
+ {"xyz.openbmc_project.Configuration.ADM1266",
+ "xyz.openbmc_project.Configuration.ADM1272",
+ "xyz.openbmc_project.Configuration.ADM1275",
+ "xyz.openbmc_project.Configuration.ADM1278",
+ "xyz.openbmc_project.Configuration.DPS800",
+ "xyz.openbmc_project.Configuration.INA219",
+ "xyz.openbmc_project.Configuration.INA230",
+ "xyz.openbmc_project.Configuration.IPSPS",
+ "xyz.openbmc_project.Configuration.ISL68137",
+ "xyz.openbmc_project.Configuration.ISL68220",
+ "xyz.openbmc_project.Configuration.ISL68223",
+ "xyz.openbmc_project.Configuration.ISL69243",
+ "xyz.openbmc_project.Configuration.ISL69260",
+ "xyz.openbmc_project.Configuration.LM25066",
+ "xyz.openbmc_project.Configuration.MAX16601",
+ "xyz.openbmc_project.Configuration.MAX20710",
+ "xyz.openbmc_project.Configuration.MAX20730",
+ "xyz.openbmc_project.Configuration.MAX20734",
+ "xyz.openbmc_project.Configuration.MAX20796",
+ "xyz.openbmc_project.Configuration.MAX34451",
+ "xyz.openbmc_project.Configuration.pmbus",
+ "xyz.openbmc_project.Configuration.PXE1610",
+ "xyz.openbmc_project.Configuration.RAA228000",
+ "xyz.openbmc_project.Configuration.RAA228228",
+ "xyz.openbmc_project.Configuration.RAA229004",
+ "xyz.openbmc_project.Configuration.TPS546D24",
+ "xyz.openbmc_project.Configuration.XDPE12284"})};
static std::vector<std::string> pmbusNames = {
"adm1266", "adm1272", "adm1275", "adm1278", "dps800", "ina219",