blob: 3901120b573fc5c77af9f97000d9c299ba133962 (
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
26
|
// This source code is released into the public domain.
export module nihil.core:skipws;
import nihil.std;
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
|