Splits a literal string with a delimiter.
More...
#include <literal_string_util.hpp>
|
static constexpr std::string_view | view {S} |
|
static constexpr auto | value |
|
Splits a literal string with a delimiter.
- Template Parameters
-
S | The literal string. |
Delimiter | The delimiter. |
◆ value
Initial value:= [] {
constexpr auto group_count = [] {
std::size_t count{};
std::size_t index{};
while ((index = view.find(Delimiter, index)) != std::string_view::npos) {
count++;
index += Delimiter.size();
}
return count + 1;
}();
std::array<std::string_view, group_count> result{};
auto iter = result.begin();
for (std::size_t start_index = 0, end_index = view.find(Delimiter);;
start_index = end_index + Delimiter.size(), end_index = view.find(Delimiter, start_index)) {
*(iter++) = view.substr(start_index, end_index - start_index);
if (end_index == std::string_view::npos) {
break;
}
}
return result;
}()
The documentation for this struct was generated from the following file: