util: Remove charconv
Change-Id: Ib423bb1c351e6624442557d58efbb1eb8b2d6b6c
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/src/types.cpp b/src/types.cpp
index 0d20d7d..8467b76 100644
--- a/src/types.cpp
+++ b/src/types.cpp
@@ -2,8 +2,6 @@
#include <fmt/format.h>
-#include <charconv>
-
void phosphor::network::IfAddr::invalidPfx(uint8_t pfx)
{
throw std::invalid_argument(fmt::format("Invalid prefix {}", pfx));
diff --git a/src/util.cpp b/src/util.cpp
index 23c642f..675409f 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -10,7 +10,6 @@
#include <sys/wait.h>
#include <cctype>
-#include <charconv>
#include <phosphor-logging/elog-errors.hpp>
#include <phosphor-logging/log.hpp>
#include <string>
@@ -133,10 +132,12 @@
return std::nullopt;
}
intf.remove_prefix(pfx.size());
- auto last = intf.data() + intf.size();
- unsigned long idx;
- auto res = std::from_chars(intf.data(), last, idx);
- if (res.ec != std::errc() || res.ptr != last)
+ unsigned idx;
+ try
+ {
+ idx = DecodeInt<unsigned, 10>{}(intf);
+ }
+ catch (...)
{
return std::nullopt;
}
diff --git a/test/test_util.cpp b/test/test_util.cpp
index 3978b1e..8ad2136 100644
--- a/test/test_util.cpp
+++ b/test/test_util.cpp
@@ -4,7 +4,6 @@
#include <fmt/chrono.h>
#include <netinet/in.h>
-#include <charconv>
#include <cstddef>
#include <cstring>
#include <stdexcept>