C++ Essence Library 0.1.0
A Utility Library for Modern C++ Programming
Loading...
Searching...
No Matches
essence::meta::split_of< S, Delimiter > Struct Template Reference

Splits a literal string with a set of delimiters. More...

#include <literal_string_util.hpp>

Static Public Attributes

static constexpr auto value
 

Detailed Description

template<literal_string S, literal_string Delimiter>
struct essence::meta::split_of< S, Delimiter >

Splits a literal string with a set of delimiters.

Template Parameters
SThe literal string.
DelimiterThe delimiters.

Member Data Documentation

◆ value

template<literal_string S, literal_string Delimiter>
auto essence::meta::split_of< S, Delimiter >::value
staticconstexpr
Initial value:
= [] {
constexpr std::string_view view{S};
constexpr auto group_count =
std::count_if(S.begin(), S.end(), [](char c) { return Delimiter.contains(c); }) + 1;
std::array<std::string_view, group_count> result{};
auto iter = result.begin();
for (std::size_t start_index = 0, end_index = view.find_first_of(Delimiter);;
start_index = end_index + 1, end_index = view.find_first_of(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: