diff options
author | Dan Goodliffe <dan.goodliffe@octal.co.uk> | 2024-01-02 13:11:00 +0000 |
---|---|---|
committer | Dan Goodliffe <dan.goodliffe@octal.co.uk> | 2024-01-02 13:11:00 +0000 |
commit | 25e4cd93c01488a8db87dcf9f9e234c39b7234bb (patch) | |
tree | 0417e273d48ba40d3a4edaf0486aefdf051232b2 | |
parent | Add missing iterator include (diff) | |
download | gentoobrowse-api-25e4cd93c01488a8db87dcf9f9e234c39b7234bb.tar.bz2 gentoobrowse-api-25e4cd93c01488a8db87dcf9f9e234c39b7234bb.tar.xz gentoobrowse-api-25e4cd93c01488a8db87dcf9f9e234c39b7234bb.zip |
Remove use of Boost lexical_cast in UnpackPqTextArrayInto
-rw-r--r-- | gentoobrowse-api/domain/converters.impl.h | 11 |
1 files 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 <boost/lexical_cast.hpp> +#include <charconv> #include <iterator> namespace Slicer { @@ -12,7 +12,14 @@ namespace Slicer { virtual void consume(const std::string & s) override { - list.push_back(boost::lexical_cast<T>(s)); + if constexpr (std::is_arithmetic<T>::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: |