5#ifndef INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_STRINGS_ALGORITHM_TRIM_HPP_
6#define INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_STRINGS_ALGORITHM_TRIM_HPP_
13#include "arene/base/stdlib_choice/cstddef.hpp"
14#include "arene/base/strings/inline_string.hpp"
15#include "arene/base/strings/string_view.hpp"
33 std::size_t
const start{str.find_first_not_of(whitespace_chars())};
34 if (start == string_view::npos) {
37 return str.substr(start);
45template <std::size_t MaxLength>
47 return inline_string<MaxLength>{ltrim(string_view{str})};
56 std::size_t
const end{str.find_last_not_of(whitespace_chars())};
57 if (end == string_view::npos) {
60 return str.substr(0U, end + 1U);
68template <std::size_t MaxLength>
70 return inline_string<MaxLength>{rtrim(string_view{str})};
77constexpr auto trim(string_view
const str) ->
string_view {
return ltrim(rtrim(str)); }
84template <std::size_t MaxLength>
86 return inline_string<MaxLength>{trim(string_view{str})};
Definition array_exceptions_disabled.cpp:11
constexpr auto trim(string_view const str) -> string_view
Create a copy of the string view with leading and trailing whitespace removed.
Definition trim.hpp:77
constexpr auto whitespace_chars() -> string_view
Characters defined as whitespace to be trimmed.
Definition trim.hpp:26
constexpr auto rtrim(string_view const str) -> string_view
Create a copy of the string view with trailing whitespace removed.
Definition trim.hpp:55
constexpr auto ltrim(string_view const str) -> string_view
Create a copy of the string view with leading whitespace removed.
Definition trim.hpp:32
constexpr auto trim(inline_string< MaxLength > const &str) -> inline_string< MaxLength >
Create a copy of the string view with leading and trailing whitespace removed.
Definition trim.hpp:85
constexpr auto ltrim(inline_string< MaxLength > const &str) -> inline_string< MaxLength >
Create a copy of the string view with leading whitespace removed.
Definition trim.hpp:46
constexpr auto rtrim(inline_string< MaxLength > const &str) -> inline_string< MaxLength >
Create a copy of the string view with trailing whitespace removed.
Definition trim.hpp:69
Copyright 2026, Toyota Motor Corporation.
Definition array_exceptions_disabled.cpp:10