char_traits#
Fully qualified name: carb::cpp::char_traits
Defined in carb/cpp/detail/CharTraits.h
-
template<typename CharT>
struct char_traits : public std::char_traits<CharT># This struct provides implementations of a subset of the functions found in std::char_traits.
It is used to provide constexpr implementations of the functions because std::char_traits did not become constexpr until C++20. Currently only the methods used by omni::string and omni::string_view are provided.
Public Types
Public Static Functions
- static inline constexpr char_type *assign( ) noexcept#
Assigns
count
copies ofc
todest
.- Returns:
dest
.
- static inline constexpr char_type *move( ) noexcept#
Copies
count
characters fromsource
todest
.This function performs correctly even if
dest
andsource
overlap.- Returns:
dest
- static inline constexpr char_type *copy( ) noexcept#
Copies
count
characters fromsource
todest
.Behavior of this function is undefined if
dest
andsource
overlap.- Returns:
dest
- static inline constexpr void assign( ) noexcept#
Assigns
c
todest
.
- static inline constexpr int compare( ) noexcept#
Lexicographically compares the first
count
characters ofs1
ands2
.- Returns:
Negative value if
s1
is less thans2
. 0 ifs1
is equal tos2
. Positive value ifs1
is greater thans2
.
- static inline constexpr const char_type *find( ) noexcept#
Searches the first
count
characters ofs
for the characterch
.- Returns:
A pointer to the first character equal to
ch
, ornullptr
if no such character exists.
-
template<size_t N>
static inline constexpr std::size_t length(
) noexcept# Computes the length of a bounded array of char_type.
Note
This function is a Carbonite extension.
std::char_traits::length
behaves differently in that the array must contain achar_type(0)
character.- Template Parameters:
N – The array length of
s
.- Parameters:
s – A bounded array of
char_type
.- Returns:
The length of
s
which may equal but not exceedN
.
-
static constexpr std::size_t length(const char_type *s) noexcept#
Computes the length of
s
.Note
This function is specialized to be more secure when used with literal strings and character arrays, in which case the maximum length returned will be the number of characters of the literal string or array.
- Returns:
The length of
s
.