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

Splits a literal string with a delimiter. More...

#include <literal_string_util.hpp>

Static Public Attributes

static constexpr std::string_view view {S}
 
static constexpr auto value
 

Detailed Description

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

Splits a literal string with a delimiter.

Template Parameters
SThe literal string.
DelimiterThe delimiter.

Member Data Documentation

◆ value

template<literal_string S, literal_string Delimiter>
auto essence::meta::split< S, Delimiter >::value
staticconstexpr
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: