My Project
Functions
cstring.hpp File Reference
#include "cstdint.hpp"
#include "char_type.hpp"
#include "cstr_type.hpp"
#include "discard.hpp"
#include "is_constant_evaluated.hpp"
#include "is_void.hpp"
#include "min_of.hpp"

Go to the source code of this file.

Functions

void * bsl::builtin_memset (void *const dst, bsl::int8 const ch, bsl::uintmax const count) noexcept
 Same as std::memset with parameter checks. If dst is a nullptr, or count is 0, this function returns a nullptr without doing anything. More...
 
bsl::int32 bsl::builtin_memcmp (void const *const lhs, void const *const rhs, bsl::uintmax const count) noexcept
 Same as std::memcmp with parameter checks. If lhs, rhs are a nullptr, or count is 0, this function returns 0. More...
 
constexpr bsl::int32 bsl::builtin_strncmp (cstr_type const lhs, cstr_type const rhs, bsl::uintmax const count) noexcept
 Same as std::strncmp with parameter checks. If lhs, rhs are a nullptr, or count is 0, this function returns 0. More...
 
constexpr bsl::uintmax bsl::builtin_strlen (cstr_type const str) noexcept
 Same as std::strlen with parameter checks. If str is a nullptr, this returns 0. More...
 
constexpr cstr_type bsl::builtin_strnchr (cstr_type const str, char_type const ch, bsl::uintmax const count) noexcept
 Same as std::strnchr with parameter checks. If str is a nullptr, or count is 0, this function returns a nullptr. More...
 

Detailed Description

Function Documentation

◆ builtin_memset()

void* bsl::builtin_memset ( void *const  dst,
bsl::int8 const  ch,
bsl::uintmax const  count 
)
inlinenoexcept

Same as std::memset with parameter checks. If dst is a nullptr, or count is 0, this function returns a nullptr without doing anything.

Note
Clang currently does not have support for this function in constexpr logic.
Parameters
dstthe buffer to set to all 'ch'
chthe value to set the provided buffer to
countthe total number of bytes to set
Returns
Returns the same result as std::memset.

◆ builtin_memcmp()

bsl::int32 bsl::builtin_memcmp ( void const *const  lhs,
void const *const  rhs,
bsl::uintmax const  count 
)
inlinenoexcept

Same as std::memcmp with parameter checks. If lhs, rhs are a nullptr, or count is 0, this function returns 0.

Note
For now, this function is marked as a non-constexpr as there seems to be a bug in how this function is implemented by Clang with constexpr functions.
Parameters
lhsthe left hand side of the comparison
rhsthe right hand side of the comparison
countthe total number of bytes to compare
Returns
Returns the same result as std::memcmp.

◆ builtin_strncmp()

constexpr bsl::int32 bsl::builtin_strncmp ( cstr_type const  lhs,
cstr_type const  rhs,
bsl::uintmax const  count 
)
inlinenoexcept

Same as std::strncmp with parameter checks. If lhs, rhs are a nullptr, or count is 0, this function returns 0.

Parameters
lhsthe left hand side of the comparison
rhsthe right hand side of the comparison
countthe total number of bytes to compare
Returns
Returns the same result as std::strncmp.

◆ builtin_strlen()

constexpr bsl::uintmax bsl::builtin_strlen ( cstr_type const  str)
inlinenoexcept

Same as std::strlen with parameter checks. If str is a nullptr, this returns 0.

Parameters
stra pointer to a string to get the length of
Returns
Returns the same result as std::strlen.

◆ builtin_strnchr()

constexpr cstr_type bsl::builtin_strnchr ( cstr_type const  str,
char_type const  ch,
bsl::uintmax const  count 
)
inlinenoexcept

Same as std::strnchr with parameter checks. If str is a nullptr, or count is 0, this function returns a nullptr.

Parameters
strthe string to search
chthe character to look for.
countthe total number of character in str to search through
Returns
Returns the same result as std::strnchr.