From 25e4cd93c01488a8db87dcf9f9e234c39b7234bb Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Tue, 2 Jan 2024 13:11:00 +0000 Subject: Remove use of Boost lexical_cast in UnpackPqTextArrayInto --- gentoobrowse-api/domain/converters.impl.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/gentoobrowse-api/domain/converters.impl.h b/gentoobrowse-api/domain/converters.impl.h index abae5bb..97cc4b0 100644 --- a/gentoobrowse-api/domain/converters.impl.h +++ b/gentoobrowse-api/domain/converters.impl.h @@ -1,7 +1,7 @@ #pragma once #include "unpackPqTextArray.h" -#include +#include #include namespace Slicer { @@ -12,7 +12,14 @@ namespace Slicer { virtual void consume(const std::string & s) override { - list.push_back(boost::lexical_cast(s)); + if constexpr (std::is_arithmetic::value) { + if (std::from_chars(s.c_str(), s.c_str() + s.length(), list.emplace_back()).ec != std::error_code {}) { + throw std::domain_error {"Invalid arithmetic input"}; + } + } + else { + list.emplace_back(s); + } } private: -- cgit v1.2.3