diff options
Diffstat (limited to 'gentoobrowse-api/domain/converters.impl.h')
-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: |