std::String::basic<Char, Traits>
basic<Char, Traits>
Represents a basic string type with specified character type and traits, similar to std::basic_string in C++
Template Parameters
CharTraits
Type Aliases
char_traits = Traitschar_t = CharTsize_t = usizestring_t = libcxx::basic_string<CharT, Traits>slice_t = sliceslice_vec = vec<slice_t>char_vec = vec<CharT>
Constructors
basic
Default constructor
basic() noexceptbasic
Copy constructor
basic(const basic& other) noexceptbasic
Move constructor
basic(basic&& other) noexceptbasic
Constructor from C++ string
basic(const libcxx::basic_string<CharT, Traits>& str) noexceptbasic
Constructor from C-style string
basic(const CharT* str) noexceptbasic
Constructor with character repeated count times
basic(const CharT chr, size_t count) noexceptbasic
Constructor from C-style string with length
basic(const CharT* str, size_t len) noexceptbasic
Constructor from string slice
basic(const slice_t& s) noexceptOperators
operator=
Copy assignment operator
op =(self, const basic& other) -> &basicoperator=
Move assignment operator
op =(self, basic&& other) -> &basicoperator=
Assignment from C-style string
op =(self, const CharT* str) -> &basicoperator[]
Access character at index (mutable)
op [``](self, index: size_t) -> &CharToperator[]
Access character at index (const)
op [``](self, index: size_t) -> const &CharToperator+=
Append another string
op +=(self, const basic& other) -> &basicoperator+=
Append C-style string
op +=(self, const CharT* str) -> &basicoperator+=
Append character
op +=(self, const U chr) -> &basicoperator+
Concatenate with another string
op +(self, const basic& other) -> basicoperator+
Concatenate with C-style string
op +(self, const CharT* str) -> basicoperator+
Concatenate with character
op +(self, const U chr) -> basicoperator==
Equality comparison
op ==(self, const basic& other) -> booloperator!=
Inequality comparison
op !=(self, const basic& other) -> booloperator<
Less than comparison
op <(self, const basic& other) -> booloperator>
Greater than comparison
op >(self, const basic& other) -> booloperator<=
Less than or equal comparison
op <=(self, const basic& other) -> booloperator>=
Greater than or equal comparison
op >=(self, const basic& other) -> booloperator slice_t
Conversion to slice
op slice_t(self) -> slice_toperator as
Cast to slice
op as(self, const slice_t*) -> slice_toperator as
Cast to C-style string
op as(self, const char_t*) -> const char_t*operator in
Contains operator for slice
op in(self, needle: slice) -> booloperator in
Contains operator for character
op in(self, chr: CharT) -> boolMethods
push_back
Appends a character to the end of the string
push_back(self, c: CharT) -> voidappend
Appends another string
append(self, const basic& other) -> voidappend
Appends C-style string with length
append(self, const CharT* str, len: size_t) -> voidappend
Appends string slice
append(self, const slice_t& s) -> voidclear
Clears the string content
clear(self) -> voidreplace
Replaces portion of string with another slice
replace(self, pos: size_t, len: size_t, const slice_t& other) -> voidreserve
Reserves capacity for the string
reserve(self, new_cap: size_t) -> voidresize
Resizes the string to new size
resize(self, new_size: size_t, c: CharT = CharT()) -> voidempty
Checks if string is empty
empty(self) -> boolraw
Returns raw C-style string pointer
raw(self) -> const CharT*size
Returns the size of the string
size(self) -> size_tlength
Returns the length of the string
length(self) -> size_tis_empty
Checks if string is empty
is_empty(self) -> boolraw_string
Returns reference to underlying C++ string
raw_string(self) -> &string_tsubslice
Returns a substring
subslice(self, pos: size_t, len: size_t) -> basicl_strip
Strips whitespace from the left
l_strip(self, const char_vec& delim = {' ', '\t', '\n', '\r'}) -> basicr_strip
Strips whitespace from the right
r_strip(self, const char_vec& delim = {' ', '\t', '\n', '\r'}) -> basicstrip
Strips whitespace from both ends
strip(self, const char_vec& delim = {' ', '\t', '\n', '\r'}) -> basicsplit
Splits string by delimiter
split(self, const basic& delim, op: slice_t::Operation = slice_t::Operation::Remove) -> vec<basic>split_lines
Splits string by newlines
split_lines(self) -> vec<basic>starts_with
Checks if string starts with needle
starts_with(self, const basic& needle) -> boolstarts_with
Checks if string starts with character
starts_with(self, c: CharT) -> boolstarts_with
Checks if string starts with slice
starts_with(self, needle: slice) -> boolends_with
Checks if string ends with needle
ends_with(self, const basic& needle) -> boolends_with
Checks if string ends with character
ends_with(self, c: CharT) -> boolends_with
Checks if string ends with slice
ends_with(self, needle: slice) -> boolcontains
Checks if string contains needle
contains(self, const basic& needle) -> boolcontains
Checks if string contains character
contains(self, c: CharT) -> boollfind
Finds first occurrence of needle
lfind(self, needle: slice) -> usize?rfind
Finds last occurrence of needle
rfind(self, needle: slice) -> usize?find_first_of
Finds first occurrence of any character in needle
find_first_of(self, needle: slice) -> usize?find_last_of
Finds last occurrence of any character in needle
find_last_of(self, needle: slice) -> usize?find_first_not_of
Finds first character not in needle
find_first_not_of(self, needle: slice) -> usize?find_last_not_of
Finds last character not in needle
find_last_not_of(self, needle: slice) -> usize?