23 auto const material_ids_strings =
26 std::vector<int> material_ids;
27 for (
auto& mid_str : material_ids_strings)
29 std::size_t num_chars_processed = 0;
33 material_id = std::stoi(mid_str, &num_chars_processed);
35 catch (std::invalid_argument&)
38 "Could not parse material ID from '{}' to a valid integer.",
41 catch (std::out_of_range&)
44 "Could not parse material ID from '{}'. The integer value of "
45 "the given string exceeds the permitted range.",
49 if (num_chars_processed != mid_str.size())
52 if (
auto const it = std::find_if_not(
53 begin(mid_str) + num_chars_processed, end(mid_str),
54 [](
unsigned char const c) {
return std::isspace(c); });
58 "Could not parse material ID from '{}'. Please separate "
59 "multiple material IDs by comma only. Invalid character: "
60 "'{}' at position {}.",
61 mid_str, *it, distance(begin(mid_str), it));
65 material_ids.push_back(material_id);