| 117 | */ |
| 118 | template <typename T = std::span<const char>> |
| 119 | std::vector<T> Split(const std::span<const char>& sp, std::string_view separators, bool include_sep = false) |
| 120 | { |
| 121 | std::vector<T> ret; |
| 122 | auto it = sp.begin(); |
| 123 | auto start = it; |
| 124 | while (it != sp.end()) { |
| 125 | if (separators.find(*it) != std::string::npos) { |
| 126 | if (include_sep) { |
| 127 | ret.emplace_back(start, it + 1); |
| 128 | } else { |
| 129 | ret.emplace_back(start, it); |
| 130 | } |
| 131 | start = it + 1; |
| 132 | } |
| 133 | ++it; |
| 134 | } |
| 135 | ret.emplace_back(start, it); |
| 136 | return ret; |
| 137 | } |
| 138 | |
| 139 | /** Split a string on every instance of sep, returning a vector. |
| 140 | * |