diff --git a/include/utilityString.hpp b/include/utilityString.hpp index 38a0331..9d3ce2b 100644 --- a/include/utilityString.hpp +++ b/include/utilityString.hpp @@ -1,5 +1,6 @@ #include #include +#include /* This file will only have things related with any kind of manipulation to std::string @@ -28,4 +29,19 @@ namespace P23 { return ret; } + /* + Converts a vector of strings which contains numbers to a vector of numbers. + + Ejemplo: vec = {"1", "2", "3", "4"} + from_string_vec_to_int_vec(vec) -> {1, 2, 3, 4} + */ + std::vector from_string_vec_to_int_vec(std::vector vec) { + std::vector ret; + for (const auto& str : vec) { + int num; + std::from_chars(str.data(), str.data() + str.size(), num); + ret.push_back(num); + } + return ret; + } } \ No newline at end of file