From 2e2d1bd3b6c7776b77c33b94f30ead89367a71e6 Mon Sep 17 00:00:00 2001 From: Lexi Winter Date: Tue, 1 Jul 2025 17:07:04 +0100 Subject: add nihil.std --- nihil.util/next_word.ccm | 37 ++++++++++--------------------------- 1 file changed, 10 insertions(+), 27 deletions(-) (limited to 'nihil.util/next_word.ccm') diff --git a/nihil.util/next_word.ccm b/nihil.util/next_word.ccm index c5d3ad7..89eeaee 100644 --- a/nihil.util/next_word.ccm +++ b/nihil.util/next_word.ccm @@ -1,44 +1,27 @@ -/* - * This source code is released into the public domain. - */ - -module; - -#include -#include -#include -#include -#include - +// This source code is released into the public domain. export module nihil.util:next_word; import :skipws; namespace nihil { -/* - * Return the next word from a string_view. Skips leading whitespace, so - * calling this repeatedly will return each word from the string. - */ - -export template [[nodiscard]] -auto next_word(std::basic_string_view text, - std::locale const &locale = std::locale()) - -> std::pair, - std::basic_string_view> +// Return the next word from a string_view. Skips leading whitespace, so +// calling this repeatedly will return each word from the string. +export template +[[nodiscard]] +auto next_word(std::basic_string_view text, std::locale const &locale = std::locale()) + -> std::pair, std::basic_string_view> { text = skipws(text, locale); auto is_space = ctype_is(std::ctype_base::space, locale); auto split_pos = std::ranges::find_if(text, is_space); - return {{std::ranges::begin(text), split_pos}, - {split_pos, std::ranges::end(text)}}; + return {{std::ranges::begin(text), split_pos}, {split_pos, std::ranges::end(text)}}; } -export template -auto next_word(std::basic_string_view *text, - std::locale const &locale = std::locale()) +export template +auto next_word(std::basic_string_view *text, std::locale const &locale = std::locale()) -> std::basic_string_view { auto [word, rest] = next_word(*text, locale); -- cgit v1.2.3