5 #ifndef CXXUTILS_STRINGPARSE_H
6 #define CXXUTILS_STRINGPARSE_H
38 std::istringstream instring(
input);
40 while (instring >> token) this->push_back(token);
45 if (
num > this->
size())
return {-1};
46 std::string token = this->at(
num-1);
49 auto [
ptr, ec] = std::from_chars(token.data(), token.data() + token.size(),
result);
50 if (ec == std::errc() &&
ptr == token.data() + token.size())
return result;
51 if (ec == std::errc::invalid_argument ||
ptr != token.data() + token.size() )
return {-1};
52 if (ec == std::errc::result_out_of_range)
return {-1};
58 return num > this->
size() ? std::string{} : this->at(
num-1);