gtopt::SnakeCaseView class

Lazy, zero-copy view that yields the snake_case form of a string.

Wraps a std::string_view and emits characters on the fly: every ASCII letter is lowercased (via detail::to_lower_char) and underscores are synthesised at word boundaries according to detail::snake_needs_underscore_before. No heap allocation occurs until the caller copies the characters somewhere (e.g. inside as_label()).

Because SnakeCaseView satisfies the detail::char_range concept it can be passed directly as an argument to as_label() and as_label_into():

std::string_view cn = "GeneratorLP";
auto a = as_label(snake_case(cn), 1, 2); // "generator_lp_1_2"

Word-boundary rule (sibling to Python's inflection library):

"GeneratorLP"    → "generator_lp"
"HTTPResponse"   → "http_response"
"XMLHttpRequest" → "xml_http_request"
"userID"         → "user_id"
"Gen2Bus"        → "gen2_bus"

Public types

class iterator
using size_type = std::size_t
using value_type = char

Constructors, destructors, conversion operators

operator std::string() const explicit
Materialise the view into a std::string.
SnakeCaseView() defaulted constexpr noexcept
SnakeCaseView(std::string_view sv) explicit constexpr noexcept

Public functions

auto begin() const -> iterator noexcept
auto empty() const -> bool noexcept
auto end() const -> iterator noexcept
auto operator==(std::string_view sv) const -> bool noexcept
Compare element-by-element (after snake_case conversion) with sv.
auto size() const -> size_type noexcept