#include "conversion.hpp" #include #include auto str_to_uint(const std::string_view &str) noexcept -> ConversionResult { if (!ctre::match(str)) { return ConversionResult(false, 0U, "Not a number"); } if (!ctre::match(str)) { return ConversionResult(false, 0U, "Out of range"); } std::size_t waste_pos = 0; auto num = std::stoul(str.data(), &waste_pos, NUMBER_BASE); if (waste_pos != str.length()) { return ConversionResult(false, 0U, "Not a number"); } if (num > UINT_MAX) { return ConversionResult(false, 0U, "Out of range"); } return ConversionResult(true, static_cast(num)); }