blob: 0a15775f5d7fc59e1acb378bcb102a180bd5504a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
// This source code is released into the public domain.
export module nihil.util:skipws;
import :ctype;
namespace nihil {
// Remove leading whitespace from a string.
export template <typename Char>
[[nodiscard]]
auto skipws(std::basic_string_view<Char> text, std::locale const &locale = std::locale())
-> std::basic_string_view<Char>
{
auto is_space = ctype_is(std::ctype_base::space, locale);
auto nonws = std::ranges::find_if_not(text, is_space);
return {nonws, std::ranges::end(text)};
}
export template <typename Char>
auto skipws(std::basic_string_view<Char> *text, std::locale const &locale = std::locale()) -> void
{
*text = skipws(*text, locale);
}
} // namespace nihil
|